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 ...
随机推荐
- C++之运算符重载(1)
在前一节中曾提到过,C++中运行时的多态性主要是通过虚函数来实现的,而编译时的多态性是由函数重载和运算符重载来实现的.这一系列我将主要讲解C++中有关运算符重载方面的内容.在每一个系列讲解之前,都会有 ...
- npm获取配置,设置代理
npm获取配置有6种方式,优先级由高到底. 命令行参数. --proxy http://server:port即将proxy的值设为http://server:port. 环境变量. 以npm_con ...
- Web开发接口测试工具——Postman插件的使用(chrome浏览器)
Postman是chrome浏览器的一款插件.Postman 可以模拟 http 请求的发送,并自动解析 JSON 和 XML 的返回数据. 可以手动的去配置各类 parameter,还支持 Basi ...
- C语言的ANSI/ISO标准
摘自:http://see.xidian.edu.cn/cpp/html/1658.html 从技术上讲有两种C语言标准,一种来自ANSI(American National Standard Ins ...
- 已知json类型根据类型封装集合
1编写帮助类根绝url得到json public static string Post(string url) { string strURL = url; //创建一个HTTP请求 HttpWebR ...
- 忘记redhat linux root密码怎么办
自己VM虚拟机里安装redhat linux root密码忘了,刚开始想重新安装,但是后来想到还有linux有一个single模式,使用single可以直接进入字符界面,然后修改: 启动vm虚拟机,启 ...
- Helpers\GeoCode
Helpers\GeoCode This function connects to google maps and retrieves the lat/lon of the address provi ...
- 自问自答-hadoop在安全模式下究竟干了什么见不得人的事
本来想自己从网上搜集整理的,但是发现吴超写的刚刚好,不多不少,所以直接转载(图片失效了,用自己的图片) http://www.superwu.cn/2013/08/23/548/ 在hadoop集群的 ...
- isa-swizzling 是什么鬼?
刚看到这个名字估计很多人有点熟悉,Method Swizzling对不对,不熟悉也没关系,去看看之前的一篇文章黑魔法之Method Swizzling吧.不过也可以根据名称猜测出来所谓的isa-swi ...
- [Android]自定义dialog
吃过饭,有没有太写代码的愿望,就开始想今天工作中遇到的问题了. 有一个很有意思的东西就是Dialog,这个是基础的组件: 我们会在一些地方需要自定义弹出窗,可是用popUpWindow太小题大作,用弹 ...