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 |
WA.........??? 那位帮忙解决下!#include<iostream> #include<cmath> #include<cstring> #define N 10000 using namespace std; int prime(long n) { long i; for(i = 2; i <= sqrt(n); i++) if(n % i == 0) { return 0; break; } return 1; } int main() { long a, b, i, j, l, k; long p[N]; while(cin >> a >> b && a != -1 && b != -1) { memset(p, 0, sizeof(p)); long x = 0, y = 0; for(i = a, j = 0; i <= b; i++) { if(i == 2) y++; if(prime(i)) { p[j] = i; j++; x++; } } for(k = 0; k < j; k++) { if((p[k]-1) % 4 == 0) y++; } cout << a << ' ' << b << ' ' << x << ' ' << y << 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