Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
你的代码好挤,而且有废话.帮你改了改In Reply To:Re:改后代码... Posted by:mayp at 2007-03-16 14:01:20 #include<iostream> using namespace std; const MAX = 10000; int prime_set[MAX]; int main() { int a,x,i; fill_n(prime_set, MAX, 0); for(i = 0; i < 10; ++i) { cin >>x; a = x; if (a == 1) continue; else for (int j = 2; j <= x; ++j) { while ( (a % j) == 0 )//相当于是筛选法求素数 { a /= j; ++prime_set[j]; } if (a == 1) break; } } int last = 1; for (i = 0; i < MAX; ++i) { if (prime_set[i]) last *= (prime_set[i] + 1); last %= 10; } cout << last << endl; return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator