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));
        }
    }
  • 相关阅读:
    模版
    列表项模版
    vue eventBus 跳坑的办法
    vue适配移动端px自动转化为rem
    pc端,移动端css重置样式
    vue全局引入scss文件(推荐)
    vue安装scss,并且全局引入
    mapState
    通俗易懂的vuex-demo
    ve2.0 v-for循环报错的解决方案
  • 原文地址:https://www.cnblogs.com/rrsb/p/8318829.html
Copyright © 2011-2022 走看看