Problem Link
Problem Type : Brute Force.
Difficulty Level : Easy
Author : Imdad
Here, is the c++ implementation of this problem.
Problem Type : Brute Force.
Difficulty Level : Easy
Author : Imdad
Here, is the c++ implementation of this problem.
#include <cstdio> #include <iostream> using namespace std; #define sz 10001 typedef struct{ int a[10]; }data; data ans[sz]; void pre_calculate(){ int tmp; ans[1].a[1] = 1; for(int i = 2; i < sz; i++){ ans[i] = ans[i-1]; tmp = i; while(tmp){ ans[i].a[tmp % 10]++; tmp /= 10; } } } int main(){ int i,t,n; pre_calculate(); scanf("%d", &t); while(t--){ scanf("%d",&n); printf("%d %d %d %d %d %d %d %d %d %d\n", ans[n].a[0], ans[n].a[1], ans[n].a[2], ans[n].a[3], ans[n].a[4], ans[n].a[5], ans[n].a[6], ans[n].a[7], ans[n].a[8], ans[n].a[9]); } return 0; }
No comments:
Post a Comment