博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
CodeForces - 896A Nephren gives a riddle
阅读量:5961 次
发布时间:2019-06-19

本文共 3225 字,大约阅读时间需要 10 分钟。

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
#include
#include
#include
#include
#include
#include
using namespace std;typedef long long LL;const int maxn = 1e5+5;const int mod = 772002+233;typedef pair
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[100]={ "What are you doing at the end of the world? Are you busy? Will you save us?"};char t[100] ={ "What are you doing while sending \"\"? Are you busy? Will you send \"\"?"};char t1[50]={ "What are you doing while sending \""};char t2[50]={ "\"? Are you busy? Will you send \""};char t3[5]={ "\"?"};LL len[100];int l1,l2,l3,tot;void init(){ l1=strlen(t1),l2=strlen(t2),l3=strlen(t3); len[0]=strlen(f0); int i; for(i=1;i
=1e18) break; } tot=i;}char dfs(int n,LL k){ if(n<=tot&&k>len[n]) return '.'; else{ if(n==0) return f0[k-1]; else{ if(k<=l1) return t1[k-1]; if(n>tot || k<=l1+len[n-1]) return dfs(n-1,k-l1); if(k<=l1+len[n-1]+l2) return t2[k-1-(l1+len[n-1])]; if(k<=l1+len[n-1]*2+l2) return dfs(n-1,k-(l1+len[n-1]+l2)); return t3[k-1-(l1+len[n-1]*2+l2)]; } }}int main(){// freopen("in.txt","r",stdin); init(); int n,q; LL k; cin>>q; while(q--){ cin>>n>>k; cout<
 

 

 

转载于:https://www.cnblogs.com/fht-litost/p/8551298.html

你可能感兴趣的文章
将网络中的图片存为NSData并保存到sqlite的BLOB字段中
查看>>
Cocos2d-js-v3.2 在 mac 上配置环境以及编译到 Andorid 的注意事项(转)
查看>>
iOS用三种途径实现一方法有多个返回值
查看>>
python--class test
查看>>
从零开始理解JAVA事件处理机制(3)
查看>>
HttpURLConnection类的使用
查看>>
linux命令分析---SED (二)
查看>>
[INS-32025] 所选安装与指定 Oracle 主目录中已安装的软件冲突。
查看>>
py2与py3差别
查看>>
欧洲语言框架A1到C2,法语等级 A1、A2、B1、B2、C1、C2
查看>>
c语言中以追加只写方式打开文本文件,C语言中打开文件读取,写入的操作
查看>>
c语言编程 企业发放,求c语言编程企业员工全年销售额统计及奖金发放系..._统计师_帮考网...
查看>>
C语言编辑中午和英语库,懂英语和C语言的来
查看>>
c语言cabd快速查询的方法,滨州医学院 数据结构C语言版习题精选
查看>>
Event loop事件循环
查看>>
开始使用新 Confluence 6 站点
查看>>
thinkPHP5.0 使用PHPExcel导出Excel文件
查看>>
白话说大数据算法C4.5
查看>>
数据分布背后的逻辑
查看>>
APP轻松通过苹果IPv6审核——阿里云网络产品级解决方案
查看>>