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     

题目链接

分析 
fi由5部分拼接而成,预处理长度,因为限制了k的范围,所以只用处理到长度1e18就好。然后根据n和k递归查找所在位子的具体字符。
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#include<cstring>
#include <queue>
using namespace std;
typedef long long LL;
const int maxn = 1e5+;
const int mod = +;
typedef pair<int,int> pii;
#define X first
#define Y second
#define pb push_back
#define mp make_pair
#define ms(a,b) memset(a,b,sizeof(a))
char f0[]={"What are you doing at the end of the world? Are you busy? Will you save us?"};
char t[] ={"What are you doing while sending \"\"? Are you busy? Will you send \"\"?"};
char t1[]={"What are you doing while sending \""};
char t2[]={"\"? Are you busy? Will you send \""};
char t3[]={"\"?"};
LL len[];
int l1,l2,l3,tot;
void init(){
l1=strlen(t1),l2=strlen(t2),l3=strlen(t3);
len[]=strlen(f0); int i;
for(i=;i<maxn;i++){
len[i]=+*len[i-];
if(len[i]>=1e18) break;
}
tot=i;
}
char dfs(int n,LL k){
if(n<=tot&&k>len[n]) return '.';
else{
if(n==) return f0[k-];
else{
if(k<=l1) return t1[k-];
if(n>tot || k<=l1+len[n-]) return dfs(n-,k-l1);
if(k<=l1+len[n-]+l2) return t2[k--(l1+len[n-])];
if(k<=l1+len[n-]*+l2) return dfs(n-,k-(l1+len[n-]+l2));
return t3[k--(l1+len[n-]*+l2)];
}
}
}
int main(){
// freopen("in.txt","r",stdin);
init();
int n,q;
LL k;
cin>>q;
while(q--){
cin>>n>>k;
cout<<dfs(n,k);
} return ;
}


CodeForces - 896A Nephren gives a riddle的更多相关文章

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

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

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

  3. 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> # ...

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

  5. 寒假特训——搜索——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 ...

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

  7. CF897C Nephren gives a riddle

    思路: 递归. 比赛的时候脑抽了len[]没算够,wa了几次. 实现: #include <bits/stdc++.h> using namespace std; using ll = l ...

  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. JavaScript浏览器历史的语法小问题

    https://www.w3schools.com/jsref/met_his_back.asp This is the same as clicking the "Back button& ...

  2. Delphi7通过superobject解析JSON

    1.通过delphi程序访问PHP事先写好的webservice(查询功能),webservice返回json格式数据. 2.通过superobject读取json数据 得到效果如下: //深层级的访 ...

  3. Jira 自定义工作流

    一.添加修改工作流 打开 设置--问题--工作流 复制一个工作流,然后进去编辑页面 添加状态 增加转换动作 切换到文本,设置跳转过程中的事件 针对Stop Progress事件,修改跳转界面(界面需先 ...

  4. 【转帖】ARM的两种不同的CPU docker 应该也是支持arm的

    armel和armhf区别选择 知识经验  3年前 (2014-11-07)  20603浏览  1评论 目录 fpu单元 armel与armhf 安装armel和armhf arm-linux-gn ...

  5. Window安装Redis并设置为开机启动

    一.下载windows版本的Redis 去官网找了很久,发现原来在官网上可以下载的windows版本的,现在官网以及没有下载地址,只能在github上下载,官网只提供linux版本的下载 官网下载地址 ...

  6. Database testing test scenarios

    1 check if correct data is getting saved is database upon successful page submit2 check values for c ...

  7. Highcharts之3D柱状图

    <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content ...

  8. 配置dataimport时候 如果css样式有问题 要修改index和admin的版本号

  9. Elasticsearch中使用groovy脚本处理boolean字段的一个问题

    Elasticsearch中使用groovy脚本获取文档的bool字段值时,得到的值是字符的 'T' 或者 'F' ,而不是bool值 true 和 false . 比如文档中有一个字段是 { &qu ...

  10. nowcoder172A 中位数 (二分答案)

    二分一下答案,假设是x. 我们把大于x的看成1,小于x的看成-1,等于x的看成0 那某个区间的和如果是正的,就说明这个区间中位数大于x:如果是0,就等于x:如果是负的,就小于x: 这样的话,做一个前缀 ...