友情链接 Doge博客 gunpowder博客 东北小蟹蟹博客

[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

posted @ 2020-09-01 18:28  Ruptpsych  阅读(156)  评论(0编辑  收藏  举报