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. docker-3-常用命令(上)

      帮助命令: docker version docker info docker --help 镜像命令: docker images:     列出本地主机上的镜像     各个选项说明:    ...

  2. shiro简单入门介绍

    shiro是apache的一个java安全框架 可以完成认证,授权,加密,会话管理,基于web继承,缓存等 功能简介: 从外部来看: shiro架构  Subject:主体,代表了当前“用户”,这个用 ...

  3. oracle 通配符及regexp_count函数说明

    通配符 通配符描述示例      %:匹配包含零个或更多字符的任意字符串.WHERE title LIKE '%computer%' 将查找处于书名任意位置的包含单词 computer 的所有书名.  ...

  4. C#发送邮件类库

    public class Email { #region 发送邮件 /// <summary> /// 发送邮件 /// </summary> /// <param na ...

  5. 如何在.Net Core 2.0 App中读取appsettings.json

    This is something that strangely doesn’t seem to be that well documented and took me a while to figu ...

  6. GPIO 配置示例

    概述:学习STM32的GPIO configration /********************************************************************** ...

  7. iOS视频处理

    在iOS中,apple提供了AVFoundation 用来处理音视频,基本能满足一些常用的音视频处理需求,而且能调用的硬件编解码接口,能提高不少效率,这是其它库所不能达到的.最近做过的Recnow S ...

  8. Java敲地鼠代码

    package test; import java.awt.EventQueue; import java.awt.event.MouseAdapter; import java.awt.event. ...

  9. day 21继承

    1.了解Python2和python3类的区别:   python2.3之前使用的是经典类, 在2.3版本之后组,使用的是新式类 MRO: method resolution order  方法的查找 ...

  10. ruby做接口测试

    一. 工具选择 IDE:rubymine:http接口请求:Unirest,ruby单元测试框架:rspec 二.工程创建 新建工程,在工程目录下,执行:rspec --init:初始化rspec工程 ...