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. redis 哈希数据类型简单操作(实现购物车案例)

    这里不累赘如何安装redis和php  redis扩展,主要熟悉调用redis哈希数据类型 简单方法操作如下 1:hSet 2:hGet 4:hDel 5:hGetAll 4:hExists 5:hI ...

  2. Selenium图片上传

    方式1: 如果是input类型的标签则可直接赋值 部分代码: driver.find_element_by_name("file").send_keys("E:\\tes ...

  3. requireJS使用教程

    一:为什么要使用requireJS? 很久之前,我们所有的JS文件写到一个js文件里面去进行加载,但是当业务越来越复杂的时候,需要分成多个JS文件进行加载,比如在页面中head内分别引入a.js,b. ...

  4. HDU 1016 Prime Ring Problem(素数环问题)

    传送门: http://acm.hdu.edu.cn/showproblem.php?pid=1016 Prime Ring Problem Time Limit: 4000/2000 MS (Jav ...

  5. render 函数渲染表格的当前数据列使用

    columns7: [ { title: '编号', align: 'center', width: 90, key: 'No', render: (h, params) => { return ...

  6. ELK6.7.0 Windows 环境本地安装

    安装环境环境准备 第一次写博文,排版比较乱,理解万岁 ELK 6.7.0三件套 下载地址:https://www.elastic.co/cn/downloads/ windows环境下默认已配置jdk ...

  7. 个人开发者即时到账收款方案 BufPay.com

    BufPay 个人即时到账支付平台 前言 作为独立开发者,一般只有一个人独立奋战,做出了产品需要收款是非常麻烦的,接入支付宝微信支付都需要公司公户,而注册公司.开公户等一系列操作非常麻烦,成本也很高一 ...

  8. vue项目出现空格警告的原因及其解决办法

    原因: 因为你的Webpack 配置中大概是使用了 eslint-loader,这是用来规范代码风格的,在多人协作或大项目中推荐使用,不想要则可以在 webpack.config.js 中去掉.esl ...

  9. Django在windows系统下安装详情

    1. Django 下载地址:https://www.djangoproject.com/download/ 2. 解压到跟python安装目录平级目录: 如下图: 3.通过cmd控制台安装djang ...

  10. Django学习笔记5-url

    先来看一下普通的url的格式 {% url 'login_action'%} 但由于name没有作用域,Django在反解URL时,会在项目全局顺序搜索,当查找到第一个name指定URL时,立即返回 ...