记录编号 46922 评测结果 AAAAAAAAAA
题目名称 1146.计数器 最终得分 100
用户昵称 cstdio 是否通过 通过
代码语言 C++ 运行时间 0.003 s
提交时间 2012-10-29 21:31:05 内存使用 3.15 MiB
显示代码纯文本
#include<iostream>
#include<cstdio>
#include<cmath>
#include<iomanip>
using namespace std;
int n,s[10]={0};
int checkitout(int p){//统计10^p位上的各数字个数
	int temp=(int)pow(10,(double)p),x=temp*10,a,b=n,c=0,i;
	//cout<<temp<<endl;
	a=(n)/x;
	//cout<<p<<" sb "<<a<<" "<<temp<<" "<<x<<endl;
	for(i=0;i<=9;i++) s[i]+=a*temp;
	//if(s[0]>0) s[0]-=temp;
	s[0]-=temp;
	b%=x;
	b++;
	while(b>=temp){
		//cout<<b<<endl;
		//cout<<c<<endl;
		s[c]+=temp;
		b-=temp;
		c++;
	}
	s[c]+=b;
	//for(i=0;i<10;i++) printf("%d\n",s[i]);
}
int main(){
	freopen("count1.in","r",stdin);
	freopen("count1.out","w",stdout);
	scanf("%d",&n);
	int temp,i;
	temp=floor(log10((double)n)+1);
	//cout<<temp<<endl;
	for(i=0;i<temp;i++) checkitout(i);
	//printf("\n");
	for(i=0;i<10;i++) printf("%d\n",s[i]);
	return 0;
}