[codeforces 1277A] Happy Birthday, Polycarp! 模拟

[codeforces 1277A]  Happy Birthday, Polycarp!  模拟

总目录详见https://blog.csdn.net/mrcrack/article/details/103564004

在线测评地址http://codeforces.com/contest/1277/problem/A

Problem Lang Verdict Time Memory
A - Happy Birthday, Polycarp! GNU C++11 Accepted 30 ms 0 KB
    #include 
    int a[15],b[15],cnt,c;
    void count(int n){//数位数
    	cnt=0;
    	while(n){
    		cnt++;
    		b[cnt]=n%10,n/=10;
    	}
    }
    int main(){
    	int t,n,i,ans;
    	a[0]=0;
    	for(i=1;i<=10;i++)a[i]=a[i-1]+9;
    	scanf("%d",&t);
    	while(t--){
    		ans=0;
    		scanf("%d",&n);
    		count(n);
    		ans+=a[cnt-1];
    		c=0;
    		for(i=1;i<=cnt;i++)c*=10,c+=b[cnt];//造数
    		if(n

 

你可能感兴趣的:(codeforces)