CodeForce896 A. Nephren gives a riddle
来源:互联网 发布:淘宝店估值 编辑:程序博客网 时间:2024/06/07 05:35
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?
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).
One line containing q characters. The i-th character in it should be the answer for the i-th query.
31 11 21 111111111111
Wh.
50 691 1941 1390 471 66
abdef
104 18253 753 5304 18294 16513 1874 5844 2554 7742 474
Areyoubusy
For the first two examples, refer to f0 and f1 given in the legend.
将s2分成5部分递归。
#include<bits/stdc++.h>#define ll long long#define maxn 100010#define INF 1e18using namespace std;char s1[maxn]=" What are you doing at the end of the world? Are you busy? Will you save us?";char s2[maxn]=" What are you doing while sending \"\"? Are you busy? Will you send \"\"?";ll f[maxn],i;char ans[15];char slove(ll x,ll y){ if(y>f[x]&&x<=i) return '.'; if(x==0) return s1[y]; if(y<=34)//第一段 return s2[y]; if(y<=34+f[x-1]||x>i)//第二段 return slove(x-1,y-34); if(y<=34+f[x-1]+32)//第三段 return s2[y-f[x-1]]; if(y<=34+2*f[x-1]+32)//第四段 return slove(x-1,y-34-f[x-1]-32); return s2[y-2*f[x-1]];//第五段}int main(){ f[0]=strlen(s1)-1; i=1; while(1) { f[i]=2*f[i-1]+68; if(f[i]>INF) break; i++; } int n; scanf("%d",&n); while(n--) { ll a,b; scanf("%lld%lld",&a,&b); printf("%c",slove(a,b)); } return 0;}
- CodeForce896 A. Nephren gives a riddle
- Codeforces896A Nephren gives a riddle
- Codeforces896A Nephren gives a riddle
- A. Nephren gives a riddle dfs
- 【CF 897C】Nephren gives a riddle
- codeforces896A Nephren gives a riddle (dfs)
- codeforces 897C Nephren gives a riddle
- [codeforces] 897C Nephren gives a riddle
- CodeForce 897 C. Nephren gives a riddle
- codeforces 896A Nephren gives a riddle dfs搜索
- Codeforces Round #449 (Div. 2). C. Nephren gives a riddle
- code force 449 div2 C. Nephren gives a riddle
- Codeforces 897C Nephren gives a riddle(dfs)
- codeforces 897C Nephren gives a riddle 递归
- cf div2 #449 C.Nephren gives a riddle
- 【codeforces 897C】Nephren gives a riddle (递归)
- code force 449 div2 C. Nephren gives a riddle
- Codeforces Round #449 (Div. 1) A. Nephren gives a riddle 模拟.
- 8、用户和组管理,权限管理
- H264协议简介
- IntelliJ IDEA 使用记录
- Navicat navicatdesignquery.sql.bak 系统找不到指定路径
- win10开始菜单打不开必须注销后才能打开是怎么回事?
- CodeForce896 A. Nephren gives a riddle
- 杨辉三角
- CMD中,获取系统信息
- 树 求树的最小深度、最大深度
- pic
- Android视频编辑SDK--RDVECore来自锐动的无UI,高度抽象化API
- Android中封装自己的SDK示例和自己的总结
- windows server 2008 r2 ftp服务器
- The type javax.servlet.ServletContext cannot be resolved报错处理