http://codeforces.com/contest/896/problem/A

第i个字符串嵌套第i-1个字符串

求第n个字符串的第k个字母

dfs

#include<map>
#include<cstdio>
#include<iostream> using namespace std; typedef long long LL; char s0[]={" What are you doing at the end of the world? Are you busy? Will you save us?"};
char s1[]={" What are you doing while sending "};
char s2[]={" ? Are you busy? Will you send "};
char s3[]={" ?"}; LL f[]; void read(LL &x)
{
x=; char c=getchar();
while(!isdigit(c)) c=getchar();
while(isdigit(c)) { x=x*+c-''; c=getchar(); }
} char dfs(int x,LL y)
{
if(x<= && y>f[x]) return '.'; if(!x) return s0[y]; if(y<=) return s1[y];
y-=; if(y==) return '"';
y--; if(x>) return dfs(x-,y); if(y<=f[x-]) return dfs(x-,y);
y-=f[x-]; if(y==) return '"';
y--; if(y<=) return s2[y];
y-=; if(y==) return '"';
y--; if(y<=f[x-]) return dfs(x-,y);
y-=f[x-]; if(y==) return '"';
y--; return '?';
} int main()
{
f[]=;
for(int i=;i<;++i) f[i]=+f[i-]*;
int q;
scanf("%d",&q);
int n; LL k;
while(q--)
{
scanf("%d",&n);
read(k);
printf("%c",dfs(n,k));
}
}
A. Nephren gives a riddle
time limit per test

2 seconds

memory limit per test

256 megabytes

input

standard input

output

standard output

What are you doing at the end of the world? Are you busy? Will you save us?

Nephren is playing a game with little leprechauns.

She gives them an infinite array of strings, f0... ∞.

f0 is "What are you doing at the end of the world? Are you busy? Will you save us?".

She wants to let more people know about it, so she defines fi =  "What are you doing while sending "fi - 1"? Are you busy? Will you send "fi - 1"?" for all i ≥ 1.

For example, f1 is

"What are you doing while sending "What are you doing at the end of the world? Are you busy? Will you save us?"? Are you busy? Will you send "What are you doing at the end of the world? Are you busy? Will you save us?"?". Note that the quotes in the very beginning and in the very end are for clarity and are not a part of f1.

It can be seen that the characters in fi are letters, question marks, (possibly) quotation marks and spaces.

Nephren will ask the little leprechauns q times. Each time she will let them find the k-th character of fn. The characters are indexed starting from 1. If fn consists of less than k characters, output '.' (without quotes).

Can you answer her queries?

Input

The first line contains one integer q (1 ≤ q ≤ 10) — the number of Nephren's questions.

Each of the next q lines describes Nephren's question and contains two integers n and k (0 ≤ n ≤ 105, 1 ≤ k ≤ 1018).

Output

One line containing q characters. The i-th character in it should be the answer for the i-th query.

Examples
input
3
1 1
1 2
1 111111111111
output
Wh.
input
5
0 69
1 194
1 139
0 47
1 66
output
abdef
input
10
4 1825
3 75
3 530
4 1829
4 1651
3 187
4 584
4 255
4 774
2 474
output
Areyoubusy
Note

For the first two examples, refer to f0 and f1 given in the legend.

最新文章

  1. Java web会话简单应用
  2. springMVC+spring+hibernate 框架整合实例
  3. python画柱状图
  4. Ankh不起作用的解决方法
  5. 多线程同步_Monitor
  6. DDD:Command模式的好处
  7. Mina工具类v1.5
  8. Linux驱动学习笔记(6)信号量(semaphore)与互斥量(mutex)【转】
  9. iOS各版本特性
  10. 【转载】使用SQL Server维护计划实现数据库定时自动备份
  11. Navicat for mysql 远程连接 mySql数据库10061、1045错误问题 (转)
  12. querySelector 和 querySelectorAll 的使用
  13. Android系统的体系结构、开发语言及源码结构
  14. java 基础(匿名内部类)
  15. Windows Server 2008企业64位版防火墙添加端口的方法
  16. 如何更改Java括号中的默认对齐
  17. 为代码减负之&amp;lt;二&amp;gt;存储过程(SQL)
  18. Delphi+GDI
  19. H5前端框架推荐合集
  20. 数据结构-堆(应用篇)之堆排序法-C和C++的实现

热门文章

  1. 深入理解mybatis
  2. 2018软工实践—Beta冲刺(3)
  3. B2
  4. 索引超出了数组界限。 在 System.Collections.Generic.Dictionary`2.Resize
  5. iOS- 如何使用Alcatraz来高效的管理Xcode-Plugin(Xcode插件)
  6. PBS命令和使用
  7. 通过Get-Group导出组的成员
  8. [转帖]什么高速线缆DAC?有了有源光缆AOC为何还选择DAC?
  9. SpannableString的基本用法
  10. ACM数论之旅4---扩展欧几里德算法(欧几里德(・∀・)?是谁?)