[P1980] 级数求和
作者:互联网
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define lu unsigned long long
#define str(a,b) sprintf(a,"%llu",b)
int main(){
lu n,x,t,rk=0;
char*d;
scanf("%llu %llu",&n,&x);
lu cc(char a,lu b);
for(t=1;t<=n;t++){
rk+=cc(x+48,t);
//printf("t=%lu,rk(n)=%lu\n",t,cc(x+48,t));
}
printf("%llu",rk);
}
lu cc(char a,lu b){
char* tostr(lu a);
lu t=0,rk=0;
char*ttt=tostr(b);
for(t=0;t<=strlen(ttt);t++){
if(t[ttt]==a)
rk++;
}
free((void*)ttt);
return rk;
}
char* tostr(lu a){
char *ss=(char*)malloc(sizeof(char)*a);
str(ss,a);
return ss;
}
建议O2
标签:级数,求和,llu,char,lu,long,P1980,include,define 来源: https://www.cnblogs.com/obj-a/p/13597777.html