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.

CF&&CC百套计划1 Codeforces Round #449 A. Nephren gives a riddle的更多相关文章

  1. CF&&CC百套计划1 Codeforces Round #449 C. Willem, Chtholly and Seniorious (Old Driver Tree)

    http://codeforces.com/problemset/problem/896/C 题意: 对于一个随机序列,执行以下操作: 区间赋值 区间加 区间求第k小 区间求k次幂的和 对于随机序列, ...

  2. CF&&CC百套计划1 Codeforces Round #449 B. Ithea Plays With Chtholly

    http://codeforces.com/contest/896/problem/B 题意: 交互题 n张卡片填m个1到c之间的数,1<=n*ceil(c/2)<=m 最后填出一个单调非 ...

  3. CF&&CC百套计划4 Codeforces Round #276 (Div. 1) A. Bits

    http://codeforces.com/contest/484/problem/A 题意: 询问[a,b]中二进制位1最多且最小的数 贪心,假设开始每一位都是1 从高位i开始枚举, 如果当前数&g ...

  4. CF&&CC百套计划4 Codeforces Round #276 (Div. 1) E. Sign on Fence

    http://codeforces.com/contest/484/problem/E 题意: 给出n个数,查询最大的在区间[l,r]内,长为w的子区间的最小值 第i棵线段树表示>=i的数 维护 ...

  5. CF&&CC百套计划3 Codeforces Round #204 (Div. 1) A. Jeff and Rounding

    http://codeforces.com/problemset/problem/351/A 题意: 2*n个数,选n个数上取整,n个数下取整 最小化 abs(取整之后数的和-原来数的和) 先使所有的 ...

  6. CF&&CC百套计划3 Codeforces Round #204 (Div. 1) D. Jeff and Removing Periods

    http://codeforces.com/problemset/problem/351/D 题意: n个数的一个序列,m个操作 给出操作区间[l,r], 首先可以删除下标为等差数列且数值相等的一些数 ...

  7. CF&&CC百套计划3 Codeforces Round #204 (Div. 1) E. Jeff and Permutation

    http://codeforces.com/contest/351/problem/E 题意: 给出一些数,可以改变任意数的正负,使序列的逆序对数量最少 因为可以任意加负号,所以可以先把所有数看作正数 ...

  8. CF&&CC百套计划3 Codeforces Round #204 (Div. 1) B. Jeff and Furik

    http://codeforces.com/contest/351/problem/B 题意: 给出一个n的排列 第一个人任选两个相邻数交换位置 第二个人有一半的概率交换相邻的第一个数>第二个数 ...

  9. CF&&CC百套计划2 CodeChef December Challenge 2017 Chef And Easy Xor Queries

    https://www.codechef.com/DEC17/problems/CHEFEXQ 题意: 位置i的数改为k 询问区间[1,i]内有多少个前缀的异或和为k 分块 sum[i][j] 表示第 ...

随机推荐

  1. 软工1816 · Beta冲刺(5/7)

    团队信息 队名:爸爸饿了 组长博客:here 作业博客:here 组员情况 组员1(组长):王彬 过去两天完成了哪些任务 推进后端完成安卓端接口的开发 在测试中发现返回地图接口存在错误(待修复) 推进 ...

  2. 第三个spirit(第十四天)

    一 .进度(自习室) 本来十号要开始进行第三次冲刺,不过因为团队很多成员要进行协会和组织的换届,而且团队还换了新 人又加了人进来,所以我们今天才是第三次冲刺的第一天.我们进行了新团队的第一次会议.基于 ...

  3. 在数组中找出两数之和为10的所有组合(JAVA)

    /*利用冒泡排序实现*/ import java.util.Scanner;public class Paixun { public static void main(String[] args) { ...

  4. 浏览器播放rtmp流

    我是利用flash插件实现的,需要以下几个文件: flowplayer-3.2.8.min.js flowplayer-3.2.18.swf flowplayer.rtmp-3.2.8.swf flo ...

  5. Beta阶段——3

    一.提供当天站立式会议照片一张: 二. 每个人的工作 (有work item 的ID) (1) 昨天已完成的工作: 今天主要是对管理员功能进行改进,解决了Alpha阶段出现的一些问题 (2) 今天计划 ...

  6. IE盒模型与W3C盒模型区别

    前两天被人问到,叫我解释一下标准盒模型与IE盒模型,额,当时只能说,知道一点,但是没有深入的去探讨过,所以下来之后就自己写了例子,亲自去验证并且查看了网上的一些资料,现将其整理如下: 一.css盒模型 ...

  7. Nmap用法实例

    <给Linux系统/网络管理员的nmap的29个实用例子> https://linux.cn/article-2561-1.html

  8. 三星vs苹果 2018Q3 财报 以及国内最赚钱的公司...

    三星文字版为: 10月31日消息,据国外媒体报道,当地时间周三韩国三星电子公布季度财报,得益于市场对其存储芯片和其他零部件的强劲需求,营业利润创下历史新高.三星不仅在自家设备上使用自己生产的芯片,还向 ...

  9. es6 字符串String的扩展

    新特性:模板字符串 传统字符串 let name = "Jacky"; let occupation = "doctor"; //传统字符串拼接 let str ...

  10. 如何在Windows下查看JAVA端口占用情况(阿里面试)

    如需要确定谁占用了9050端口 为例: 1.Windows平台 在windows命令行窗口下执行: 1.查看所有的端口占用情况 C:\>netstat -ano 协议 本地地址 外部地址 状态 ...