C. 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.

思路: 字符串长度的递推式:f[n]=2*f[n-1]+l1+l2+l3,然后分成5段来找所求字母,l1-(s[n-1])-l2-(s[n-1])-l3.

代码:

 #include<bits/stdc++.h>
#define db double
#define ll long long
#define vec vector<ll>
#define Mt vector<vec>
#define ci(x) scanf("%d",&x)
#define cd(x) scanf("%lf",&x)
#define cl(x) scanf("%lld",&x)
#define pi(x) printf("%d\n",x)
#define pd(x) printf("%f\n",x)
#define pl(x) printf("%lld\n",x)
//#define rep(i, x, y) for(int i=x;i<=y;i++)
const int N = 1e6 + ;
const int mod = 1e9 + ;
const int MOD = mod - ;
const db eps = 1e-;
const db PI = acos(-1.0);
using namespace std;
string s0="What are you doing at the end of the world? Are you busy? Will you save us?",
s1="What are you doing while sending \"",s2="\"? Are you busy? Will you send \"",s3="\"?"; ll f[N]={,,,,};
int l1,l2,l3;
void init()
{
for(int i=;;i++){
ll x=f[i-]*+;
if(x>1e18) break;
f[i]=f[i-]*+;
}
}
char dfs(ll n,ll k)
{
if(!n) return k<=?s0[k-]:'.';
if(k<=l1) return s1[k-];//第一段
k-=l1;
if(k<=f[n-]||!f[n-]) return dfs(n-,k);//在范围内或者当前字符串长度远超目标位置
k-=f[n-];
if(k<=l2) return s2[k-];//s2的范围内
k-=l2;
if(k<=f[n-]||!f[n-]) return dfs(n-,k);
k-=f[n-];
return k<=l3?s3[k-]:'.';//最后一段 }
int main(){
init();
ll n,k;
int t;
ci(t);
l1=(int)s1.size(),l2=(int)s2.size(),l3=(int)s3.size();
while(t--)
{
cl(n),cl(k);
putchar(dfs(n,k));
}
return ;
}

最新文章

  1. xcode gdb/lldb调试命令
  2. JavaScript 的面向对象
  3. 给自己~~微语&amp;&amp;歌单
  4. 《所用到的AJAX技术基础》
  5. iOS Question
  6. C#之Winform中treeview控件绑定数据库
  7. atitit.导航的实现最佳实践and声明式编程
  8. Visual studio 中或IIS中使用Less预处理语言
  9. HDU 2602 Bone Collector (简单01背包)
  10. Eclipse常见设置及快捷键使用总结(更新中)
  11. 苹果所有常用证书,appID,Provisioning Profiles配置说明及制作图文教程(精)
  12. 仿简书、淘宝等等App的View弹出效果
  13. winform中相对路径和绝对路径的获取
  14. iOS -多字体混合
  15. return view详解(转载)
  16. [项目记录] 用c语言完成的一个学生成绩管理系统
  17. 一个 Vue 的滑动按钮组件
  18. gym 102059A 树链剖分后odt维护区间
  19. Redis新接触
  20. Django搭建博客记(一)

热门文章

  1. FRM-40654 Record has been updated
  2. 【Android 界面效果47】RecyclerView详解
  3. c#数据类型和表达式
  4. 构建跨平台APP开发的两本书,这里重点推荐下
  5. Azure本月最新活动,速度Mark!!
  6. 创建Gradle工程出现Could not install Gradle distribution from &#39;https://services.gradle.org/distributions/gradleXX&#39;.问题解决
  7. npm升级自身
  8. [转载]Memcached缓存服务的简单安装
  9. IOS instancetype的使用好处
  10. MVC中某个页面不需要引用母版页的正确写法