Codeforces Round #449 (Div. 2) (B、C)



B. Chtholly's request


http://codeforces.com/contest/897/problem/B






题目大意:

前k个偶数位的回文数之和  





分析:

一个数对称之后就是偶数回文







AC代码:

#include <bits/stdc++.h>
#define gcd(a,b) __gcd(a,b)
#define mset(a,x) memset(a,x,sizeof(a))
#define FIN     freopen("input","r",stdin)
#define FOUT    freopen("output","w",stdout)
const int INF=0x3f3f3f3f;
const double PI=acos(-1.0);
const int MAX=1e5+10;
typedef long long LL;
const LL mod=1e9+7;
using namespace std;
LL cal(LL x){
    LL ans=x;
    while (x){
        ans=ans*10+x%10;
        x/=10;
    }
    return ans;
}
int main (){
    LL k,p;
    while (scanf ("%lld%lld",&k,&p)!=EOF){
        LL res=0;
        for (int i=1;i<=k;i++){
            res=(res+cal(i))%p;
        }
        printf ("%lld\n",res);
    }
    return 0;
}







C. Nephren gives a riddle


http://codeforces.com/contest/897/problem/C






题目大意:

呃呃呃。。。。。。    题意不好说





分析:

事先计算 fi 的长度  k<LL    所以   n>53   以后不必再算下去    然后一层一层的找







AC代码:

#include <bits/stdc++.h>
#define gcd(a,b) __gcd(a,b)
#define mset(a,x) memset(a,x,sizeof(a))
#define FIN     freopen("input","r",stdin)
#define FOUT    freopen("output","w",stdout)
const int INF=0x3f3f3f3f;
const double PI=acos(-1.0);
const int MAX=1e5+10;
typedef long long LL;
const LL mod=1e9+7;
using namespace std;
string f0="What are you doing at the end of the world? Are you busy? Will you save us?";
string temp1="What are you doing while sending \"";
string temp2="\"? Are you busy? Will you send \"";
string temp3="\"?";
LL l0=f0.length();
LL l1=temp1.length();
LL l2=temp2.length();
LL l3=temp3.length();
LL countx[MAX];
void init(){
    mset(countx,INF);
    countx[0]=l0;
    countx[1]=l1+l2+l3+countx[0]*2;
    for (int i=2;countx[i-1]<=(LL)1e18;i++){
        countx[i]=2*countx[i-1]+l1+l2+l3;
    }
}
char dfs(int n,LL k){
    if (n==0) return f0[k-1];
    if(k<=l1) return temp1[k-1];// 34
    k-=l1;
    if(k<=countx[n-1]) return dfs(n-1,k);
    k-=countx[n-1];
    if(k<=l2) return temp2[k-1];// 32
    k-=l2;
    if(k<=countx[n-1]) return dfs(n-1,k);
    k-=countx[n-1];
    if (k<=l3) return temp3[k-1];// 2
}
int main (){
    init();
    int q;
    scanf ("%d",&q);
    LL n,k;
    for (int i=0;i<q;i++){
        scanf ("%lld%lld",&n,&k);
        if (k>countx[n]&&n<=53) printf (".");
        else printf ("%c",dfs(n,k));
    }
    putchar('\n');
    return 0;
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值