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,...9separated 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
#include <iostream>
#include <cstring>
using namespace std;
int main()
{
int a[15];
int t,n;
cin>>t;
while(t--)
{
memset(a,0,sizeof(a));
cin>>n;
for(int i=1;i<=n;i++)
{
int t=i;
while(t)
{
int num=t%10;
a[num]++;
t/=10;
}
}
for(int i=0;i<10;i++)
{
if(i)
cout<<" ";
cout<<a[i];
}
cout<<endl;
}
return 0;
}

最新文章

  1. Modernizr.js:为HTML5和CSS3而生!
  2. memcache的一致性hash算法使用
  3. 使用CSS修改HTML5 input placeholder颜色
  4. 使用getJSON()方法异步加载JSON格式数据
  5. firefly 环境配置所需工具
  6. Django操作数据库
  7. SVN二次开发——让SVN、TSVN(TortoiseSVN)支持windows的访问控制模型、NTFS ADS(可选数据流、NTFS的安全属性)
  8. HTTP协议头部与Keep-Alive模式详解
  9. 1.cocos2dx存储卡的游戏代码、而游戏移植到“华为荣耀”电话、问题的总结移植
  10. HttpClient的巨坑
  11. php开发之常用验证方法
  12. ArrayList 原码解析
  13. node通过QQ邮箱发送邮件
  14. MySQL共享表空间概念
  15. logstash报错401 需要在logstash启动的配置文件中增加es的用户名和密码
  16. 高可用Hadoop平台-答疑篇
  17. lineman 的理念与 modern web app
  18. 层层递进——宽度优先搜索(BFS)
  19. 使用Linux命令行测试网速-----speedtest-cli
  20. hashset和treeset的区别

热门文章

  1. 我要带徒弟学JAVA架构 ( 写架构,非用架构 )
  2. [Angular] Freshness Caching Policy - Network First, Cache Last
  3. UVA10862 - Connect the Cable Wires(递推 + java的大数)
  4. java中tcp小样例
  5. Redis(三)、Redis主从复制
  6. SpringBoot中拦截器和过滤器的使用
  7. JAVA 中for-each循环使用方法
  8. 修改织梦data目录名
  9. 基于Intent实现Activity与Activity之间的数据传递,实现二个Activity的跳转功能
  10. 4185 Oil Skimming 最大匹配 奇偶建图