|
|
back to boardWA#1 Posted by ooo 16 Dec 2008 20:09 #include <iostream.h> double a[1000000]; int sum(int); bool prost(int); int main() { int y=0,i,t,I,J; double N; cin>>I>>J; t=I; for(i=J;i>=I;i--)if(prost(i)) {cout<<i;y++; break;} if(y==0) {for(i=0;i<=J-I;i++) {a[i]=(sum(t))/t;t++;} N=a[0]; for(i=1;i<=J-I;i++) if(a[i]<N) N=a[i]; cout<<N;} return 0;} int sum(int x) {int s=0,i; for(i=1;i<=x/2;i++) if(x%i==0) s+=i; return s;} bool prost(int x) {int i; if(x==2) return true; else for(i=2;i<=x/2;i++) if(x%i==0) return false; return true;} |
|
|