UVa 1225 - Digit Counting
来源:互联网 发布:surface装mac 编辑:程序博客网 时间:2024/05/21 07:57
昨天上午开始写的,后来遇到了问题,RE了两次,就一直没做,今天Ac了455之后,换了个思路,把这个Ac了。
#include <stdio.h>#include <string.h>#define maxn 40000int main (){ int n,t,i,j,count,first; char a[maxn]; int b[10][2]={0}; scanf("%d",&t); while(t--) { memset(a,0,sizeof(a)); count=0; first=1; for(i=0;i<10;i++) { b[i][0]=i; b[i][1]=0; } scanf("%d",&n); if(n>=10) { for(i=1;i<10;i++) { a[count]=i+48; count++; } if(n>=100) { for(i=10;i<100;i++) { a[count]=i/10+48; count++; a[count]=i%10+48; count++; } if(n>=1000) { for(i=100;i<1000;i++) { a[count]=i/100+48; count++; a[count]=(i%100)/10+48; count++; a[count]=i%10+48; count++; } for(i=1000;i<n+1;i++) { a[count]=i/1000+48; count++; a[count]=(i%1000)/100+48; count++; a[count]=(i%100)/10+48; count++; a[count]=(i%10)+48; count++; } } else { for(i=100;i<n+1;i++) { a[count]=i/100+48; count++; a[count]=(i%100)/10+48; count++; a[count]=i%10+48; count++; } } } else { for(i=10;i<n+1;i++) { a[count]=i/10+48; count++; a[count]=i%10+48; count++; } } } else for(i=1;i<n+1;i++) { a[count]=i+48; count++; } for(i=0;i<10;i++) { for(j=0;j<maxn;j++) { if(!a[j]) break; if(b[i][0]==a[j]-48) b[i][1]++; } } for(i=0;i<10;i++) { if(first) { printf("%d",b[i][1]); first=0; } else printf(" %d",b[i][1]); } printf("\n"); } return 0;}
0 0
- UVa 1225 - Digit Counting
- UVa 1225 - Digit Counting
- UVa-1225 - Digit Counting
- UVa 1225 Digit Counting
- UVA - 1225 Digit Counting
- UVA 1225 - Digit Counting
- UVa 1225 - Digit Counting
- UVa-1225Digit Counting
- 【Uva 1225】 Digit Counting
- UVa 1225 - Digit Counting
- UVa 1225 - Digit Counting
- Uva - 1225 - Digit Counting
- Uva 1225 Digit Counting
- UVA 1225 Digit Counting
- UVa 1225 - Digit Counting
- UVa 1225 Digit Counting
- UVa 1225 Digit Counting
- UVA - 1225 Digit Counting
- 浅谈 a different object with the same identifier value was already associated with the session错误
- POJ2407_Relatives【欧拉phi函数】【基本】
- POJ 1014 DP
- IOS monkey test
- 64位Win7下的Rational Rose2003 安装和破解
- UVa 1225 - Digit Counting
- css学习心得总结
- mysql数据库远程连接授权
- 类似于金山电池波纹效果的
- docker学习笔记(1)
- PowerDesigner使用教程|使用方法
- glDrawArrays(int mode, int first,int count)
- magento 调取最新订单号/ /更新属性,或者更新价格时,性能优化
- [CJ]设计模式之单例