#include <bits/stdc++.h>
using namespace std;
long long mp[10000001];
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
//freopen("ws.INP", "r", stdin);
//freopen("ws.OUT", "w", stdout);
memset(mp, 0, sizeof mp);
int a, b; cin >> a >> b;
long long res = 0;
for (int i = 1; i <= b; i++) {
mp[i] += i;
if (i >= a) res += abs(mp[i]);
for (int j = i * 2; j <= b; j += i)
mp[j] -= i;
} cout << res;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
39 ms |
78532 KB |
Output is correct |
2 |
Correct |
40 ms |
78508 KB |
Output is correct |
3 |
Correct |
41 ms |
78532 KB |
Output is correct |
4 |
Correct |
1550 ms |
78564 KB |
Output is correct |
5 |
Correct |
1532 ms |
78608 KB |
Output is correct |
6 |
Correct |
1548 ms |
78568 KB |
Output is correct |
7 |
Correct |
1415 ms |
78592 KB |
Output is correct |
8 |
Correct |
334 ms |
78572 KB |
Output is correct |