思路:

递归。

比赛的时候脑抽了len[]没算够,wa了几次。

实现:

  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. using ll = long long;
  4. const string s = "What are you doing at the end of the world? Are you busy? Will you save us?";
  5. const string t = "What are you doing while sending \"";
  6. const string v = "\"? Are you busy? Will you send \"";
  7. const ll len_s = s.length();
  8. const ll len_t = t.length();
  9. const ll len_v = v.length();
  10. ll len[];
  11. char dfs(ll n, ll k)
  12. {
  13. if (n == )
  14. {
  15. if (k >= && k <= len_s) return s[k - ];
  16. else return '.';
  17. }
  18. else if (n >= )
  19. {
  20. if (k <= len_t) return t[k - ];
  21. return dfs(n - , k - len_t);
  22. }
  23. else
  24. {
  25. if (k <= len_t) return t[k - ];
  26. else if (k > len_t && k <= len_t + len[n - ])
  27. return dfs(n - , k - len_t);
  28. else if (k > len_t + len[n - ] && k <= len_t + len[n - ] + len_v)
  29. return v[k - len_t - len[n - ] - ];
  30. else if (k > len_t + len[n - ] + len_v && k <= len_t + * len[n - ] + len_v)
  31. return dfs(n - , k - len_t - len[n - ] - len_v);
  32. else if (k == len_t + * len[n - ] + len_v + )
  33. return '\"';
  34. else if (k == len_t + * len[n - ] + len_v + )
  35. return '?';
  36. else return '.';
  37. }
  38. }
  39. int main()
  40. {
  41. len[] = (ll)len_s;
  42. for (int i = ; i <= ; i++)
  43. {
  44. len[i] = len[i - ] * + len_t + len_v + ;
  45. }
  46. ll q, n, k;
  47. cin >> q;
  48. while (q--)
  49. {
  50. cin >> n >> k;
  51. cout << dfs(n, k);
  52. }
  53. return ;
  54. }

CF897C Nephren gives a riddle的更多相关文章

  1. CodeForces - 896A Nephren gives a riddle

    A. Nephren gives a riddle time limit per test 2 seconds memory limit per test 256 megabytes input st ...

  2. CF&&CC百套计划1 Codeforces Round #449 A. Nephren gives a riddle

    http://codeforces.com/contest/896/problem/A 第i个字符串嵌套第i-1个字符串 求第n个字符串的第k个字母 dfs #include<map> # ...

  3. Codeforces Round #449 [ C/A. Nephren gives a riddle ] [ D/B. Ithea Plays With Chtholly ]

    PROBLEM C/A. Nephren gives a riddle 题 http://codeforces.com/contest/896/problem/A codeforces 896a 89 ...

  4. 寒假特训——搜索——H - Nephren gives a riddle

    What are you doing at the end of the world? Are you busy? Will you save us? Nephren is playing a gam ...

  5. A. Nephren gives a riddle

    What are you doing at the end of the world? Are you busy? Will you save us? Nephren is playing a gam ...

  6. Codeforces Round #449 (Div. 2)-897A.Scarborough Fair(字符替换水题) 897B.Chtholly's request(处理前一半) 897C.Nephren gives a riddle(递归)

    A. Scarborough Fair time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

  7. Codeforces 897C Nephren gives a riddle:模拟【珂学】

    题目链接:http://codeforces.com/contest/897/problem/C 题意: 给你一些字符串: A: [What are you doing at the end of t ...

  8. Codeforces 897 C.Nephren gives a riddle-递归

    C. Nephren gives a riddle   time limit per test 2 seconds memory limit per test 256 megabytes input ...

  9. Codeforces Round #449 (Div. 2)ABCD

    又掉分了0 0. A. Scarborough Fair time limit per test 2 seconds memory limit per test 256 megabytes input ...

随机推荐

  1. Mycat集群方案收集(待实践)

    先收集,后续再实践. 我想,市面上开源方案中,涉及到高可用和负载均衡的部署,无论是哪一个产品应用,都基本离不开LVS+Keepalived+HAProxy+Nginx等等. 下面是收集的教程: htt ...

  2. atom的react自动补全插件

    atom-react-autocomplete–项目内,组件名及状态的自动补全 autocomplete-js-import–模块导入智能提示 emmet-jsx-css-modules– React ...

  3. paramiko错误信息:Paramiko error: size mismatch in put

    在使用paramiko的put往远处服务器上传资源的时候,出现类似下面的错误信息 The code in paramiko's sftp_client.py:putfo() reads at the ...

  4. 使用RoboCopy 命令[转载]

    经常进行文件管理操作的朋友们,不满意于Windows系统内置的复制功能,因为它太龟速了.于是大家就使用FastCopy.TeraCopy之类的软件来加速复制,但是你是否知道Windows 7已经内置快 ...

  5. Hadoop 执行过程中出现 name node is in safe mode 问题

    解决方法: 1.进入hadoop安装根目录 如 :我的hadoop 安装在/usr/local/hadoop 执行 cd /usr/local/hadoop bin/hadoop dfsadmin - ...

  6. JSP自己定义标签入门实例具体解释

    JSP自己定义标签主要能用到的两个包 javax.servlet.jsp.*;javax.servlet.jsp.tagext.*; 自己定义标签<userInfo:showUserInfo/& ...

  7. docker (1) ---简介,使用

    一.docker简介: 容器( container-based )虚拟化方案,充分利用了操作系统本身已有的机 制和特性,以实现轻量级的虚拟化(每个虚拟机安装的不是完整的虚拟机), 甚至有人把他称为新一 ...

  8. 工作总结 default Console.WriteLine(default(Guid));

    泛型代码中的默认关键字 在泛型类和泛型方法中产生的一个问题是,在预先未知以下情况时,如何将默认值分配给参数化类型 T: T 是引用类型还是值类型. 如果 T 为值类型,则它是数值还是结构. 给定参数化 ...

  9. hdu 4778 Gems Fight!

    第一次写状压dp-- 题意:http://blog.csdn.net/dyx404514/article/details/15506601 状压dp+博弈吧-- #include<iostrea ...

  10. js 对有“命名空间”的表单做深度解析

    问题描写叙述:一个大表单中,可能包括几十个字段.这些字段在数据库中的映射非常可能不在一张表中,为了降低后台操作的工作量,我们应该在前台提交的时候对数据做初步处理. 举例说明: watermark/2/ ...