1 #include <iostream> 2 #include <sstream> 3 #include <string> 4 #include <algorithm> 5 #include <vector> 6 using namespace std; 7 8 #define GI ({int _t; scanf("%d", &_t); _t;}) 9 #define FOR(i, a, b) for (int i=a; i<b; i++) 10 #define REP(i, a) FOR(i, 0, a) 11 template<class T> string toString(T n){ostringstream ost;ost<<n;ost.flush();return ost.str();} 12 int toInt(string s){int r=0;istringstream sin(s);sin>>r;return r;} 13 #define DBG(x) cout << #x << "::" << x << endl; 14 #define DBGV(_v) { REP(_i, _v.size()) { cout << _v[_i] << "\t";} cout << endl;} 15 16 int primes[] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97}; 17 int main() { 18 while (1) { 19 int num = GI; 20 if (num == 0) break; 21 vector <int> count(28, 0); 22 FOR(i, 2, num+1) { 23 int cur = i; 24 REP(j, 26) { 25 if (cur==1) break; 26 while (cur%primes[j] == 0) { 27 cur/=primes[j]; 28 count[j]++; 29 } 30 } 31 } 32 printf("%3d! =", num); 33 int pos = 0; 34 REP(i, 26) if(count[i] > 0) pos++; 35 REP(i, 26) { 36 if (i%15 == 0 && i != 0 && i != pos && count[i] != 0) printf("\n "); 37 if (count[i] == 0) break; 38 printf("%3d", count[i]); 39 } 40 printf("\n"); 41 } 42 return 0; 43 }