1. 程式人生 > >UVA-1225 Digit Counting

UVA-1225 Digit Counting

bsp names math mem input pac spa code list

 1 #include <iostream>
 2 #include <stdlib.h>
 3 #include <string>
 4 #include <vector>
 5 #include <algorithm>
 6 #include <string.h>
 7 #include <stack>
 8 #include <unordered_map>
 9 #include <math.h>
10 #include <iomanip>
11 
12 using namespace
std; 13 14 int hashList[10002][10]; 15 16 int main() 17 { 18 int T; 19 cin >> T; 20 memset(hashList,0,sizeof(hashList)); 21 for(int i = 1; i <= 10001; i ++) 22 { 23 int tmpNum = i; 24 for(int j = 0;j < 10;j ++) 25 { 26 hashList[i][j] = hashList[i-1
][j]; 27 } 28 while(tmpNum) 29 { 30 hashList[i][tmpNum%10] ++; 31 tmpNum /= 10; 32 } 33 } 34 while(T --) 35 { 36 int input; 37 cin >> input; 38 for(int i = 0;i < 9;i ++) 39 { 40 cout << hashList[input][i] << "
"; 41 } 42 cout << hashList[input][9]; 43 cout << endl; 44 } 45 return 0; 46 }

UVA-1225 Digit Counting