NC25094. [USACO 2006 Dec B]Dream Counting
描述
输入描述
Line 1: Two space-separated integers: M and N
输出描述
Line 1: Ten space-separated integers that are the counts of the number of each digit (0..9) that appears while counting through the sequence.
示例1
输入:
129 137
输出:
1 10 2 9 1 1 1 1 0 1
说明:
One zero, ten ones, etc.C++11(clang++ 3.9) 解法, 执行用时: 17ms, 内存消耗: 488K, 提交时间: 2019-07-03 19:32:38
#include<bits/stdc++.h> using namespace std; int f[10]; int main(){ int a,b; cin>>a>>b; for(int i=a;i<=b;i++){ int j=i; while(j){ f[j%10]++; j/=10; } } for(int i=0;i<=8;i++) cout<<f[i]<<" "; cout<<f[9]<<"\n"; return 0; }