#include <bits/stdc++.h>
using namespace std;
#define sp << " " <<
#define int long long
#define vi vector<int>
#define pb push_back
#define F(xxx,yyy) for (int xxx=1;xxx<=yyy;xxx++)
#define pii pair<int,int>
#define all(x) x.begin()+1,x.end()
const int N = 1e7+1;
int d[N];
int sieve[N];
int expo(int x,int y) {
if (!y) return 1;
int e = expo(x,y/2);
e*=e;
if (y&1) e*=x;
return e;
}
void solve() {
for (int i=2;i<N;i++) {
if (!sieve[i]) {
sieve[i] = i;
for (int j=i*i;j<N;j+=i)sieve[j] = i;
}
}
d[1] = 1;
for (int i=2;i<N;i++) {
int p = sieve[i];
int c = 0;
int j = i;
while (j%p == 0) j/=p,c++;
d[i] = d[j]*(expo(p,c+1)-1)/(p-1);
}
int a,b;
cin >> a >> b;
int ans = 0;
for (int i=a;i<=b;i++) ans+=abs(i-(d[i]-i));
cout << ans << endl;
}
signed main() {
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int t = 1;
//cin >> t;
while (t --> 0) solve();
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
311 ms |
131072 KB |
Execution killed with signal 9 |
2 |
Runtime error |
301 ms |
131072 KB |
Execution killed with signal 9 |
3 |
Runtime error |
310 ms |
131072 KB |
Execution killed with signal 9 |
4 |
Runtime error |
305 ms |
131072 KB |
Execution killed with signal 9 |
5 |
Runtime error |
311 ms |
131072 KB |
Execution killed with signal 9 |
6 |
Runtime error |
303 ms |
131072 KB |
Execution killed with signal 9 |
7 |
Runtime error |
304 ms |
131072 KB |
Execution killed with signal 9 |
8 |
Runtime error |
308 ms |
131072 KB |
Execution killed with signal 9 |