思路:

递归。

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

实现:

 #include <bits/stdc++.h>
using namespace std;
using ll = long long;
const string s = "What are you doing at the end of the world? Are you busy? Will you save us?";
const string t = "What are you doing while sending \"";
const string v = "\"? Are you busy? Will you send \"";
const ll len_s = s.length();
const ll len_t = t.length();
const ll len_v = v.length();
ll len[];
char dfs(ll n, ll k)
{
if (n == )
{
if (k >= && k <= len_s) return s[k - ];
else return '.';
}
else if (n >= )
{
if (k <= len_t) return t[k - ];
return dfs(n - , k - len_t);
}
else
{
if (k <= len_t) return t[k - ];
else if (k > len_t && k <= len_t + len[n - ])
return dfs(n - , k - len_t);
else if (k > len_t + len[n - ] && k <= len_t + len[n - ] + len_v)
return v[k - len_t - len[n - ] - ];
else if (k > len_t + len[n - ] + len_v && k <= len_t + * len[n - ] + len_v)
return dfs(n - , k - len_t - len[n - ] - len_v);
else if (k == len_t + * len[n - ] + len_v + )
return '\"';
else if (k == len_t + * len[n - ] + len_v + )
return '?';
else return '.';
}
}
int main()
{
len[] = (ll)len_s;
for (int i = ; i <= ; i++)
{
len[i] = len[i - ] * + len_t + len_v + ;
}
ll q, n, k;
cin >> q;
while (q--)
{
cin >> n >> k;
cout << dfs(n, k);
}
return ;
}

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. pydevd 一次trouble shooting

    只是一次小的trouble shooting. 關於python的遠程調試功能.但是由於思路混亂.浪費了許多時間,記錄一下整個過程.作爲改進的參考. 问题背景: 我之前一直在ubuntu上用pycha ...

  2. CentOS 5.11开启VNC Service

    1.     #yum install vncserver 2.     #vncpasswd       此密码将成为vnc的login password          password:    ...

  3. iOS开发项目实战——Swift实现图片轮播与浏览

    近期開始开发一个新的iOS应用,自己决定使用Swift.进行了几天之后,发现了一个非常严峻的问题.那就是无论是书籍,还是网络资源,关于Swift的实在是太少了,随便一搜全都是OC实现某某某功能.就算是 ...

  4. HDU 1030 数学题

    给出两点,求这两点在图上的最短路径 分别以最上,左下,右下为顶点,看这个三角图形 ans=这三种情况下两点的层数差 #include "stdio.h" #include &quo ...

  5. C#.NET 如何打开高版本的sln文件

    我用VS2008去打开2010版本的解决方案,提示如下   其实我可以直接打开这个csproj文件并运行   关闭之后就会提示是否创建一个新的 sln文件

  6. DMA32映射问题

    近期在调试PCIe的行情加速卡的驱动.当中使用DMA在CPU和FPGA间数据传输. 最開始使用的是低16M的DMA ZONE的内存,用slab分配器的kmalloc分配获取.但因为最新的需求,须要使用 ...

  7. 怎样用fiddler2捕获移动设备上的http或者https请求

    调试移动设备上的问题.看不到发送的请求和得到的响应是比較难过的,fiddler能够实现样的功能. 原理: 在PC上启动fiddler.将手持设备的网络代理改成fiddler. 这样全部的请求和响应都经 ...

  8. C#之快速排序 C#之插入排序 C#之选择排序 C#之冒泡排序

    C#之快速排序   算法描述 1.假定数组首位元素为“枢轴”,设定数列首位(begin)与末位(end)索引: 2.由末位索引对应元素与“枢轴”进行比较,如果末位索引对应元素大于“枢轴”元素,对末位索 ...

  9. cocos2d-x 2.2.3 建project

    2.2以后不再使用模板安装了. 打开终端,进入cocos2d-x文件夹下的tools/project-creator,运行命令 ./create_project.py -project [项目名] - ...

  10. 树状数组 LA 4329 亚洲赛北京赛区题

    复习下树状数组 还是蛮有意思的一道题: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&cat ...