Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<cstdlib>
- #include<vector>
- #define long long long
- #define nln '\n'
- using namespace std;
- int main()
- {
- cin.tie(0)->sync_with_stdio(0);
- cout.tie(0)->sync_with_stdio(0);
- //freopen("perfectornot.inp", "r", stdin);
- long a, b;
- cin >> a >> b;
- vector<long> s(b+1, 1);
- s[1] = 0;
- for (long i = 2; i <= b; ++i)
- for (long j = 2*i; j <= b; j += i)
- s[j] += i;
- long ans = 0;
- for (long i = a; i <= b; ++i)
- ans += abs(i-s[i]);
- cout << ans << nln;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment