Sicily 1068欢迎提出优化方案
1608. Digit Counting
限制条件
时间限制: 1 秒, 内存限制: 32 兆
题目描述
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 <tex2html_verbatim_mark>(1 < N < 10000) <tex2html_verbatim_mark>. After that, he counts the number of times each digit (0 to 9) appears in the sequence. For example, with N = 13 <tex2html_verbatim_mark>, 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.
输入格式
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 <tex2html_verbatim_mark>.
输出格式
For each test case, write sequentially in one line the number of digit 0, 1,...9 <tex2html_verbatim_mark>separated by a space.
样例输入
2
3
13
样例输出
0 1 1 1 0 0 0 0 0 0
1 6 2 2 1 1 1 1 1 1
题目来源
2007 Danang, Vietnam
我都做出来,当然是简单题……
#include<iostream>
using namespace std;
int main()
{
int n,N;
int a[]={}; //store the number of 0 to 9
cin>>n;
for(int i=;i<n;i++){
int a[]={};
cin>>N;
for(int j=;j<N+;j++){
int p=j;
while(p/ != ){a[p%]++;p=p/;}
a[p]++;
}
for(int k=;k<;k++) cout<<a[k]<<" ";
cout<<endl;
}
return ;
}
Sicily 1068欢迎提出优化方案的更多相关文章
- Sicily 1510欢迎提出优化方案
这道题我觉得是除1000(A-B)外最简单的题了……不过还是提出一个小问题:在本机用gcc编译的时候我没包括string.h头文件,通过编译,为什么在sicily上却编译失败? 1510. Mispe ...
- sicily 1200欢迎提出优化方案
水题来的……我的做法是用a[10]数组表示每个数字出现的次数. 1200. Stick 限制条件 时间限制: 1 秒, 内存限制: 32 兆 题目描述 Anthony has collected a ...
- iOS界面跳转的一些优化方案
原文地址: http://blog.startry.com/2016/02/14/Think-Of-UIViewController-Switch/ iOS界面跳转的一些优化方案 App应用程序开发, ...
- (转)Web性能优化方案
第一章 打开网站慢现状分析 在公司访问部署在IDC机房的VIP网站时会感觉很慢.是什么原因造成的?为了缩短页面的响应时间,改进我们的用户体验,我们需要知道用户的时间花在等待什么东西上. 可以跟踪一下我 ...
- AngularJS应用页面切换优化方案
葡萄城的一款尚在研发中的产品,对外名称暂定为X项目.其中使用了已经上市的Wijmo中SpreadJS产品,另外,在研发过程中整理了一些研发总结分享给大家.如本篇的在页面切换的过程中优化方案,欢迎大家跟 ...
- AngularJs应用页面切换优化方案(转)
目录[-] 前言 场景 使用resolve来提前请求数据 为页面加入切换动画 总结 葡萄城的一款尚在研发中的产品,对外名称暂定为X项目.其中使用了已经上市的wijmo中SpreadJS产品,另外,在研 ...
- Adapter优化方案的探索
概要:使用Adapter的注意事项与优化方案本文的例子都可以在结尾处的示例代码连接中看到并下载,如果喜欢请star,如果觉得有纰漏请提交issue,如果你有更好的点子可以提交pull request. ...
- Web性能优化方案
第一章 打开网站慢现状分析 在公司访问部署在IDC机房的VIP网站时会感觉很慢.是什么原因造成的?为了缩短页面的响应时间,改进我们的用户体验,我们需要知道用户的时间花在等待什么东西上. 可以跟踪一下我 ...
- 大批量delete 优化方案
超过100万以上数据 删除的时候 会非常慢且产生大量日志文件 最大的问题是内存爆表 导致得多次重启服务才能删除整个库 暂时提出初步优化方案 1.设置日志为简单模式,处理完后恢复 ALTER DATAB ...
随机推荐
- MaterialViewPager
https://github.com/florent37/MaterialViewPager
- android短信的接收和发送处理
一 初始化 手机开机初始化调用GSMPhone 构造函数. GSMPhone (Context context, CommandsInterface ci, PhoneNotifier notifie ...
- MAC JAVA 环境变量那些事
1,查看 JAVA 的版本号 akdeMacBook-Pro:bin AK$ java -version java version "1.6.0_65" Java(TM) SE R ...
- C++中创建对象的时候加括号和不加括号的区别
c++创建对象的语法有----- 1 在栈上创建 MyClass a; 2 在堆上创建加括号 MyClass *a= new MyClass(); 3 不加括号 MyClass *a = new My ...
- 1050. String Subtraction (20)
this problem is from PAT, which website is http://pat.zju.edu.cn/contests/pat-a-practise/1050. firs ...
- 随机森林实现 MATLAB
matlab 中随机森林工具箱的下载地址: http://code.google.com/p/randomforest-matlab/downloads/detail?name=Windows-Pre ...
- 小米2s使用Hexamob Recovery PRO恢复数据
这东西对于手机来说, 真是神器啊 现在很多手机都是以MTP连接到电脑的, 所以在PC上是看不到盘符, 也就无法使用finaldata 之类的工具恢复了. 而像小米2S这样的手机, 无法外接SD卡, 则 ...
- 《Entity Framework 6 Recipes》中文翻译——第九章EntityFramework在N层架构程序中的应用(七)
在WCF服务中的序列化代理 问题 您有一个从查询返回的动态代理对象,你想要把它像POCO对象已经进行序列化.在序列化基于实体对象的POCO(普通旧CLR对象)时,实体框架会自动生成一个动态生成的派生类 ...
- B. Mr. Kitayuta's Colorful Graph
B. Mr. Kitayuta's Colorful Graph time limit per test 1 second Mr. Kitayuta has just bought an undi ...
- python分页和session和计算时间差
分页 #!/usr/bin/env python # -*- coding:utf-8 -*- class Pagenation: def __init__(self,current_page,all ...