UVa-1225 - Digit Counting:simple
2015-11-25 00:02
344 查看
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<map>
#include<string>
//#define LOCAL
using namespace std;
#define maxn 10000+5
int main()
{
#ifdef LOCAL
freopen("in.txt","r",stdin);
//freopen("out.txt","w",stdout);
#endif
int t,n;
map<int,int>M;
scanf("%d",&t);
while(t--){
for(int i=0;i<=9;i++)
M[i]=0;
int tmp;
scanf("%d",&n);
for(int i=1;i<=n;i++){
tmp=i;
while(tmp){
M[tmp%10]++;
tmp/=10;
}
}
for(int i=0;i<=9;i++)
if(i)
printf(" %d",M[i]);
else
printf("%d",M[i]);
printf("\n");
}
return 0;
}
#include<cstdio>
#include<cstring>
#include<iostream>
#include<map>
#include<string>
//#define LOCAL
using namespace std;
#define maxn 10000+5
int main()
{
#ifdef LOCAL
freopen("in.txt","r",stdin);
//freopen("out.txt","w",stdout);
#endif
int t,n;
map<int,int>M;
scanf("%d",&t);
while(t--){
for(int i=0;i<=9;i++)
M[i]=0;
int tmp;
scanf("%d",&n);
for(int i=1;i<=n;i++){
tmp=i;
while(tmp){
M[tmp%10]++;
tmp/=10;
}
}
for(int i=0;i<=9;i++)
if(i)
printf(" %d",M[i]);
else
printf("%d",M[i]);
printf("\n");
}
return 0;
}
相关文章推荐
- 甘肃回转反吹扁袋除尘器厂家介绍
- 浙江袋式除尘器介绍
- iMindMap字体如何进行修改
- ios 实时监测网络状况
- OS X下UNIX环境高级编程(第三版)学习日志-第一章ChapterI,程序和进程
- ERROR-2:React
- mybatis generator project src does not exist
- 码农啊码农(前端工程师)
- ovs笔记
- 5-30 Table Tennis (30分)
- 在ubuntu中配置jdk安装eclipse
- bfs
- 转载的是linuxtone论坛上的前辈学运维的经验,用于共勉。
- MySQL存储过程
- hadoop伪分布式搭建,运行 wordcount
- 提高视力的有效方法是什么?
- webservice+restful+cxf(服务端客户端调用)
- qd
- c# .net开发工程师
- HTML基本介绍