zoukankan      html  css  js  c++  java
  • codeforce 896A

    这是一道很有意思的题。

    我们递归统计其出现的位置,就好了。

    #include<bits/stdc++.h>
    #define LL long long
    using namespace std;
    char F[] = "What are you doing at the end of the world? Are you busy? Will you save us?";
    char A[] = "What are you doing while sending "";
    char B[] = ""? Are you busy? Will you send "";
    char C[] = ""?";
    const LL FL = strlen(F);
    const LL AL = strlen(A);
    const LL BL = strlen(B);
    const LL CL = strlen(C);
    const LL ALL = FL+AL+BL+CL;
    int T; LL n,q;
    char solve(LL a,LL b){
        if(!a) { if(b>FL) return '.';else return F[(b-1)%FL];}
        if(b<=AL) return A[(b-1)%AL];
        if(a>=57) return solve(a-1,b-AL);
        LL lastL = 1;
        lastL<<=a-1; lastL*=ALL; lastL-=(AL+BL+CL); 
        if(b<=AL) return A[(b-1)%AL];
        b-=AL;
        if(b<=lastL) return solve(a-1,b);
        b-=lastL; 
        if(b<=BL) return B[(b-1)%BL];
        b-=BL;
        if(b<=lastL) return solve(a-1,b);
        b-=lastL;
        if(b<=CL) return C[(b-1)%CL];
        return '.';
    }
    int main () {
        scanf("%d",&T);
        while (T--) {
            scanf("%lld %lld",&n,&q);
            putchar(solve(n,q));
        }
    }
  • 相关阅读:
    前端资源网址
    IDEA激活工具
    新建jsp项目
    jsp笔记
    iOS的SVN
    iOS学习网站
    测试接口工具
    MVP模式
    关于RxJava防抖操作(转)
    注释模板
  • 原文地址:https://www.cnblogs.com/rrsb/p/8318829.html
Copyright © 2011-2022 走看看