UVa 1225 Digit Counting:枚举2014-07-25
1225 - Digit Counting
Time limit: 3.000 secondshttp://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=show_problem&problem=3666N<10000,干脆O(NlogN)建表得了。完整代码:
/*0.012s*/#include<cstdio>int c[10000][10];int main(){int i, k, t, n;for (i = 1; i < 10000; ++i){for (k = i; k; k /= 10) ++c[i][k % 10];for (; k < 10; ++k) c[i][k] += c[i - 1][k];}scanf("%d", &t);while (t--){scanf("%d", &n);for (i = 0; i < 9; ++i)printf("%d ", c[n][i]);printf("%d
", c[n][9]);}return 0;}
作者:csdn博客 synapse7