#include <bits/stdc++.h>
#define ll long long int
using namespace std;
ll sum_div(int n) {
if (n == 1) return 0;
ll sum = 1;
for (int i = 2; i * i <= n; ++i) {
if (i * i == n) sum += i;
else if (n % i == 0) {
sum += i + n / i;
}
}
return sum;
}
int main()
{
int a, b;
cin >> a >> b;
ll ans = 0;
for (int i = a; i <= b; ++i) {
ans += abs(i - sum_div(i));
}
cout << ans << '\n';
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
124 ms |
412 KB |
Output is correct |
4 |
Correct |
20 ms |
344 KB |
Output is correct |
5 |
Execution timed out |
3052 ms |
348 KB |
Time limit exceeded |
6 |
Execution timed out |
3028 ms |
600 KB |
Time limit exceeded |
7 |
Execution timed out |
3065 ms |
344 KB |
Time limit exceeded |
8 |
Execution timed out |
3039 ms |
348 KB |
Time limit exceeded |