比赛的时候以为是找规律,想法也跟这个做法差不多了。。就是想太慢了,还差一点想到用递归,确实不太熟练,希望能通过打cf提高一下思维速度。不知道是不是China round的原因,十点就开始了,搞错时间以为是十一点开始,这场吃了饭之后才来,过了四十多分钟才交题,semi rated都还涨了35…
题意很好理解,就是你猜你猜我猜你猜我猜你猜不猜这种……判断k的长度,是fn的前面一节就输出,是fn-1里面的一节的话就递归去fn-1了。
/*
http://codeforces.com/contest/897/problem/C
*/
#include<bits/stdc++.h>
#define INF 0x3f3f3f3f
#define PI acos(-1.0)
#define LL long long
using namespace std;
inline LL read();
const int MAXN = 1e5+10;
string s0 = "What are you doing at the end of the world? Are you busy? Will you save us?",
s1 = "What are you doing while sending \"",s2 = "\"? Are you busy? Will you send \"",s3 = "\"?";
LL len[MAXN];
LL len0 = s0.size(),len1 = s1.size(),len2 = s2.size(),len3 = s3.size();
char fun(LL n,LL k)
{
if(!n)
{
if(k <= len0)
return s0[k-1];
else
return '.';
}
if(k <= len1)
return s1[k-1];
k -= len1;
if(k <= len[n-1] || !len[n-1])
return fun(n-1,k);
k -= len[n-1];
if(k <= len2)
return s2[k-1];
k -= len2;
if(k <= len[n-1] || !len[n-1])
return fun(n-1,k);
k -= len[n-1];
if(k <= len3)
return s3[k-1];
return '.';
}
int main(void)
{
int q = read();
len[0] = len0;
LL tmp = len1+len2+len3;
for(int i = 1;len[i-1] <= 1e18; ++i)
{
len[i] = 2*len[i-1]+tmp;
}
while(q--)
{
LL n = read(),k = read();
putchar(fun(n,k));
}
}
inline LL read()
{
LL x=0,f=1;char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
return x*f;
}