POJ 2603
1 #include<iostream> 2 #include<stdio.h> 3 #define M 350000 4 #define N 30000 5 using namespace std; 6 7 int boo[10000]; 8 int prime[N]; 9 void give_list(); 10 int main() 11 { 12 memset(boo,0,sizeof(int)*10000); 13 give_list(); 14 //freopen("acm.acm","r",stdin); 15 int tem; 16 int sum; 17 int i; 18 int j; 19 int ans; 20 sum = 1; 21 ans = 1; 22 for(j = 0; j < 10; ++ j) 23 { 24 cin>>sum; 25 for(i = 0; i < N; ++ i) 26 { 27 28 while(sum % prime[i] == 0) 29 { 30 ++ boo[prime[i]]; 31 sum /= prime[i]; 32 if(sum == 1) 33 break; 34 } 35 if(sum == 1) 36 break; 37 } 38 } 39 ans = 1; 40 for(i = 0; i < 10000; ++ i) 41 { 42 if(boo[i]) 43 ans *= ++boo[i]; 44 } 45 cout<<ans%10<<endl; 46 system("pause"); 47 } 48 49 void give_list() 50 { 51 bool prime_1[M]; 52 int i; 53 int j; 54 memset(prime_1,true,sizeof(bool)*M); 55 prime_1[1] = false; 56 for(i = 2; i < M; ++ i) 57 { 58 if(prime_1[i]) 59 { 60 j = i * 2; 61 while(j < M) 62 { 63 prime_1[j] = false; 64 j = j + i; 65 } 66 } 67 } 68 j = 0; 69 for(i = 2; i < M; ++ i) 70 { 71 if(prime_1[i]) 72 { 73 prime[j] = i; 74 ++ j; 75 } 76 } 77 }