#include <bits/stdc++.h>
using namespace std;
long long f(int n){
if(n==1) return 1;
long long ans = n;
for(int i=1;i<=sqrt(n);i++){
if(n%i==0){
ans -= i;
if(i!=1 and i*i!=n){
ans -= (n/i);
}
}
}
return abs(ans);
}
int main(){
int a,b;
cin >> a >> b;
long long ans = 0;
for(int i=a;i<=b;i++){
ans += f(i);
}
cout << ans << endl;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
129 ms |
408 KB |
Output is correct |
4 |
Correct |
20 ms |
348 KB |
Output is correct |
5 |
Execution timed out |
3066 ms |
348 KB |
Time limit exceeded |
6 |
Execution timed out |
3053 ms |
348 KB |
Time limit exceeded |
7 |
Execution timed out |
3067 ms |
348 KB |
Time limit exceeded |
8 |
Execution timed out |
3039 ms |
348 KB |
Time limit exceeded |