|
|
вернуться в форумThe time limit Good afternoon! I am a programmer-beginner. I have written the code for this task on c++, but the time limit is exceeded on the second test! The code is this: ( https://ideone.com/Rh98zQ) #include <iostream> using namespace std; float ghj(int a) {int m; m=0; for(int l=1; l<a; l++) {if(a%l==0) {m=m+l;}} float c=(float(int(m))); float b=c/a; return b;} int main() { int i,j; cin >> i >> j; float p=ghj(i); int n=i; for(int o=i; o<=j; o++) {if(ghj(o)<p) {p=ghj(o); n=o;}} cout << n; return 0; } Tell me, please, how can I optimize the code? |
|
|