|
|
вернуться в форумi have seen the ac pro of pas,but i use c++ but can't got AC,any master can help me ? Послано kkgz 21 апр 2004 08:50 #include<iostream.h> #include<math.h> #include<limits.h> main() { long D,U,i,sum,crno,minN,j; double min,ratio,nouse; int flag=0; cin>>D>>U; min=1000000; minN=D; for(long t=1000000;t>=2;t--) { U=t; if(D==1) cout<<'0'; else { for(i=U;i>=D;i--) { sum=1;
for(j=2;j<=sqrt((double)i);j++) { if(i%j==0) { sum+=j+i/j; } } if(i%(j-1)==0) sum-=j;
ratio=double(sum)/(double)i; if(ratio<=min) {
min=ratio; minN=i; if(sum==1) { for(long k=U;k>=D;k--) {
if(modf(sqrt((double)k),&nouse)==0) { ratio=(1+sqrt((double)k))/(double)k; if(ratio>min) break; else {
min=k; minN=k; break; } } } break; }
} } cout<<minN; } } } Re: i have seen the ac pro of pas,but i use c++ but can't got AC,any master can help me ? if there are prime numbers in the interval you should print it. Else, if there are not primes in the interval, it is quite small and you can brute search the number. If the first bound of the interval is 1 you must print 1 (I got many WAs not knowing this). Re: i have seen the ac pro of pas,but i use c++ but can't got AC,any master can help me ? I'm doing exactly that but I keep getting WA. Could you give me some sample inputs/outputs? |
|
|