Trung is bored with his mathematics homeworks. He takes a piece of chalk and starts writing a sequence
of consecutive integers starting with 1 to N (1 < N < 10000). After that, he counts the number of
times each digit (0 to 9) appears in the sequence. For example, with N = 13, the sequence is:
12345678910111213
In this sequence, 0 appears once, 1 appears 6 times, 2 appears 2 times, 3 appears 3 times, and each
digit from 4 to 9 appears once. After playing for a while, Trung gets bored again. He now wants to
write a program to do this for him. Your task is to help him with writing this program.
Input
The input file consists of several data sets. The first line of the input file contains the number of data
sets which is a positive integer and is not bigger than 20. The following lines describe the data sets.
For each test case, there is one single line containing the number N.
Output
For each test case, write sequentially in one line the number of digit 0, 1, . . . 9 separated by a space.
Sample Input
2
3
13
Sample Output
0 1 1 1 0 0 0 0 0 0
1 6 2 2 1 1 1 1 1 1

题意:把1到n的数字排列起来,数0到9之间的数出现的次数,最后输出每个出现的次数

 #include<bits/stdc++.h>
using namespace std;
int ans[];
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
memset(ans,,sizeof(ans));
int n;
scanf("%d",&n);
for(int i=;i<=n;i++)
{
int temp=i;
while(temp>)
{
ans[temp%]++;
temp/=;
}
}
for(int i=;i<;i++)
{
printf("%d ",ans[i]);
}
printf("%d\n",ans[]);
}
return ;
}

uvaoj1225Digit Counting(暴力)的更多相关文章

  1. POJ 1971-Parallelogram Counting,暴力1063ms!

    Parallelogram Counting 刚学hash还不会用,看到5000ms的时限于是想着暴力来一发应该可以过.以前做过类似的题,求平行四边形个数,好像是在CF上做的,但忘了时限是多少了,方法 ...

  2. ZOJ3944People Counting<暴力/枚举>

    题意:输入一张照片,给出人物的特征,判断有多少个人. .O. /|\ (.) 思路:按照3*3的图统计,只要有一个点符合就加1 #include<cstdio> #include<i ...

  3. HDU5952 Counting Cliques (暴力深搜+剪枝) (2016ACM/ICPC亚洲赛区沈阳站 Problem E)

    题目链接:传送门 题目: Counting Cliques Time Limit: / MS (Java/Others) Memory Limit: / K (Java/Others) Total S ...

  4. [ACM_暴力][ACM_几何] ZOJ 1426 Counting Rectangles (水平竖直线段组成的矩形个数,暴力)

    Description We are given a figure consisting of only horizontal and vertical line segments. Our goal ...

  5. CF990G GCD Counting 点分治+容斥+暴力

    只想出来 $O(nlogn\times 160)$ 的复杂度,没想到还能过~ Code: #include <cstdio> #include <vector> #includ ...

  6. ZOJ3944 People Counting ZOJ3939 The Lucky Week (模拟)

    ZOJ3944 People Counting ZOJ3939 The Lucky Week 1.PeopleConting 题意:照片上有很多个人,用矩阵里的字符表示.一个人如下: .O. /|\ ...

  7. Counting Rectangles

    Counting Rectangles Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 1043 Accepted: 546 De ...

  8. HDU 5952 Counting Cliques 【DFS+剪枝】 (2016ACM/ICPC亚洲区沈阳站)

    Counting Cliques Time Limit: 8000/4000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) ...

  9. XTU OJ 1210 Happy Number (暴力+打表)

    Problem Description Recently, Mr. Xie learn the concept of happy number. A happy number is a number ...

随机推荐

  1. POJ 3368 Frequent values 【ST表RMQ 维护区间频率最大值】

    传送门:http://poj.org/problem?id=3368 Frequent values Time Limit: 2000MS   Memory Limit: 65536K Total S ...

  2. CI框架源码研读(整体架构)

    有人说phper的深入要从研读mvc框架开始,我跳了一个常用的CI框架入手,主要是因为 CI框架简单轻巧,可以自己DIY功能!!! 1.首先来看CI的整体架构图: 其中:application是用户级 ...

  3. 关注磁盘的两个指标: IOPS 和传输带宽(吞吐量)

    ㈠ IOPS                磁盘的 IOPS.也就是每秒能进行多少次IO        那么.如何才算一次IO呢?        其实.这是个定义很混乱的问题        因为.系统 ...

  4. 集合HashMap和HashSet中迭代器的使用

    package setTest; import java.util.HashMap;import java.util.HashSet;import java.util.Iterator;import ...

  5. Android平台上PMEM的使用及Platform设备注册(二)

    三.注册PMEM设备 这里我们除了描述PMEM设备,还将注册一个拥有memory空间和IRQ资源的示例设备example_device. 对于example_device,定义如下结构体: stati ...

  6. get-pip.py 安装

    http://www.pip-installer.org/en/latest/installing.html$ curl http://pypi.python.org/packages/source/ ...

  7. EF Core如何输出日志到Visual Studio的输出窗口

    我们在使用EF Core的时候,很多时候需要在Visual Studio的输出窗口中知道EF Core在后台生成的SQL语句是什么,这个需求可以通过自定义EF Core的ILoggerFactory和 ...

  8. 阿里云云服务器Windows Server 2012 R2无法安装IIS等组件的解决办法

    Windows Server2012 R2数据中心版 不管安装什么组件,都显示存储空间不足,无法应用命令,错误代码0x80070008. 最终确认是服务器配置过低的原因,因为这个型号是低级别的配置,1 ...

  9. 分别用Eclipse和IDEA搭建Scala+Spark开发环境

    开发机器上安装jdk1.7.0_60和scala2.10.4,配置好相关环境变量.网上资料很多,安装过程忽略.此外,Eclipse使用Luna4.4.1,IDEA使用14.0.2版本. 1. Ecli ...

  10. 类似"音速启动"的原创工具简码"万能助手"在线用户数终于突破100了!

    原本只是开发出来方便自己的一个小工具,看到群友也喜欢,就随手分享了, 经过1个多月的自然积累,在线用户数终于突破100了,这增长速度实在让人泪奔~ 博客园的朋友如果看到,喜欢的话就拿去用吧, 万能助手 ...