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.

题目大意:
就是给你q组数据,每一组有两个数,一个是第n句话,一个是这个第n句话中的第k个字母,求出这个字母。
给你第0句话和第一句话,让你进行递归搜索。
思路:
这个是看了很多题解,比较简单的一种
就是无论是第几句话,都分成五个部分,第一个就是双引号前面的,第二个是双引号中间的,第三个是第一个双引号后面
第二个双引号前面的,第四个是第二个双引号,第五个是第二个双引号后面的。
根据k判断它在这五个部分中的哪一个,找到后就进行定位输出。
具体:
先写一个长度函数,根据n句话判断它的长度,因为当n==55,len[n]==5e18了,所以就不需要往后算,而且也算不了。
因为再往后就超出范围了。
为什么不用算呢?因为这个是递归,而且k范围是1e18,所以不会有k>len[55]的情况出现。所以在n>=55,k都会在第一个
输出或者第二个部分进入下一个dfs。

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <algorithm>
using namespace std;
typedef long long ll;
char f0[]="What are you doing at the end of the world? Are you busy? Will you save us?";
char f1[]="What are you doing while sending \"\"? Are you busy? Will you send \"\"?";
const int maxn=1e5+10;
const ll inf=1e18; ll len[maxn];
void init()
{
len[0]=strlen(f0);
int l=strlen(f1);
for(int i=1;i<=55;i++) len[i]=2*len[i-1]+l;
for(int i=56;i<=100000;i++) len[i]=len[55];
} char dfs(int n,ll k)
{
if(n==0)
{
if(k<len[0]) return f0[k];
return '.';
}
if(k<34) return f1[k];
k-=34;
if(k<len[n-1]) return dfs(n-1,k);
k-=len[n-1];
if(k<32) return f1[k+34];
k-=32;
if(k<len[n-1]) return dfs(n-1,k);
k-=len[n-1];
if(k<2) return f1[k+66];
return '.';
} int main()
{
int q;
scanf("%d",&q);
int n;
ll k;
init();
while(q--)
{
scanf("%d%I64d",&n,&k);
k--;//因为数组原因
char ans=dfs(n,k);
putchar(ans);
}
return 0;
}

  

寒假特训——搜索——H - Nephren gives a riddle的更多相关文章

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

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

  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. Gym 101655:2013Pacific Northwest Regional Contest(寒假自训第13场)

    A .Assignments 题意:给定距离D,以及N个飞机的速度Vi,单位时间耗油量Fi,总油量Ci.问有多少飞机可以到达目的地. 思路:即问多少飞机满足(Ci/Fi)*Vi>=D  ---- ...

  5. Gym101986: Asia Tsukuba Regional Contest(寒假自训第12场)

    A .Secret of Chocolate Poles 题意:有黑白两种木块,黑色有1,K两种长度: 白色只有1一种长度,问满足黑白黑...白黑形式,长度为L的组合种类. 思路:直接DP即可. #i ...

  6. 寒假特训——I - Fair

    Some company is going to hold a fair in Byteland. There are nn towns in Byteland and mm two-way road ...

  7. Gym 101889:2017Latin American Regional Programming Contest(寒假自训第14场)

    昨天00.35的CF,4点才上床,今天打的昏沉沉的,WA了无数发. 题目还是满漂亮的. 尚有几题待补. C .Complete Naebbirac's sequence 题意:给定N个数,他们在1到K ...

  8. Gym.102006:Syrian Collegiate Programming Contest(寒假自训第11场)

    学习了“叙利亚”这个单词:比较温和的一场:几何的板子eps太小了,坑了几发. A .Hello SCPC 2018! 题意:给定一个排列,问它是否满足,前面4个是有序的,而且前面4个比后面的都小. 思 ...

  9. Gym.101955: Asia Shenyang Regional Contest(寒假自训第10场)

    C.Insertion Sort 题意:Q次询问,每次给出N,M,Mod,问你有多少种排列,满足前面M个数字排序之后整个序列的LIS>=N-1. 思路:我们把数字看成[1,M],[N-M+1,N ...

随机推荐

  1. npm 安装 卸载 模块(转载)

    来源 https://blog.csdn.net/yihanzhi/article/details/75665959 利用npm 安装删除模块 npm安装模块 [npm install xxx]利用 ...

  2. vb.net 與 SQLite連線

    Dim ModuleSql As String Dim n As Integer 'SQLite連線Dim connSQLite As New Data.SQLite.SQLiteConnection ...

  3. [android] 采用断点调试的方式观察pull解析的流程

    当程序出现错误的时候,界面出不来,这个时候就需要调试技巧,描述这个程序在哪个地方出现的问题.在你认为可能出错的代码部分,左侧的行号栏点击打断点,在项目目录右键 ==>debug as ==> ...

  4. (7)Microsoft office Word 2013版本操作入门_常用技巧

    1.自定义快速功能栏调整:常用功能按钮可以设置显示到此处.(如图所示的另存为和插入批注功能) 2.word中截图功能: 2.1 截图插入后的图片,可以进行设置  选中图片---点击[格式]可以设置图片 ...

  5. Puppeteer之爬虫入门

    译者按: 本文通过简单的例子介绍如何使用Puppeteer来爬取网页数据,特别是用谷歌开发者工具获取元素选择器值得学习. 原文: A Guide to Automating & Scrapin ...

  6. 课程作业——熟悉常用的Linux操作

    cd命令:切换目录 (1) 切换到目录 /usr/local cd /usr/local (2) 去到目前的上层目录 cd .. (3) 回到自己的主文件夹 cd ~ ls命令:查看文件与目录 (4) ...

  7. PHP 无限极分类下拉列表实现

    1. 递归实现下拉列表 /** * @param 递归 实现下拉列表 分类 */ include('db.inc.php'); function getList($pid = 0,&$resu ...

  8. CSS用法总结(持续更新)

    一.html,body{height:100%} 解决了容器高度不足(容器高度由子元素高度决定,而%按照父元素的百分比),无法用%布局页面的问题 把html和body的高度设置为浏览器高度,此时会出现 ...

  9. 5; XHTML图像

    1.背景图案的设置 2.将图片插入到网页中去 3.用图像作为超链接 4.使用工具建立地图索引 5.切片索引 6.为网站添加图标 5.1 背景图案的设置 格式:<body background=” ...

  10. Spring 切入点配置

    有关各种拦截的切入点配置举例 (1)只对返回值为String的方法进行拦截 @Pointcut("execution (java.lang.String com.zzdr.spring.se ...