# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1105932 | DangKhoizzzz | Savrsen (COCI17_savrsen) | C++14 | 433 ms | 39672 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e7;
int sieve[MAXN + 5];
void init()
{
for(int i = 1; i <= MAXN; i++) sieve[i] = i;
for(int i = 2; i*i <= MAXN; i++)
{
if(sieve[i] == i)
{
for(int j = i * i; j <= MAXN; j += i)
{
sieve[j] = i;
}
}
}
}
long long f(int n) {
long long res = 1;
while(n > 1) {
int d = sieve[n];
int e = 1;
while(n % d == 0) e++, n /= d;
long long sum = 0, pw = 1;
while(e--) {
sum += pw;
pw *= d;
}
res *= sum;
}
return res;
}
int main()
{
init();
int l, r; cin >> l >> r;
long long res = 0;
for(int x = l; x <= r; x++)
res += abs(x - (f(x) - x));
cout << res << '\n';
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |