#include <bits/stdc++.h>
#define maxN 10000010
using namespace std;
int sum[maxN];
int main()
{
int a, b;
cin >> a >> b;
for (int d = 1; d <= b; ++d)
{
int mul = 2;
while (mul <= b / d)
{
sum[d * mul] += d;
mul++;
}
}
long long res = 0;
for (int i = a; i <= b; ++i) res += abs(sum[i] - i);
cout << res;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
2 ms |
588 KB |
Output is correct |
4 |
Correct |
1281 ms |
39408 KB |
Output is correct |
5 |
Correct |
1290 ms |
39404 KB |
Output is correct |
6 |
Correct |
1296 ms |
39492 KB |
Output is correct |
7 |
Correct |
1226 ms |
36336 KB |
Output is correct |
8 |
Correct |
224 ms |
10228 KB |
Output is correct |