# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1088868 | Sunbae | Savrsen (COCI17_savrsen) | C++17 | 1088 ms | 39516 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>
typedef long long ll;
using namespace std;
int s[10000001];
ll powr(ll A, int B){
ll res = 1;
while(B){
if(B&1) res *= A;
A *= A;
B>>=1;
}
return res;
}
signed main(){
int A, B; scanf("%d %d", &A, &B);
s[1] = 1;
for(int i = 2; i<=B; i+=2) s[i] = 2;
for(int i = 3; i<=B; i+=2) s[i] = i;
for(ll i = 3; i<=B; i+=2){
if(s[i] == i){
for(ll j = i*i; j<=B; j+=i+i) s[j] = min(s[j], (int)i);
}
}
ll tot = 0;
for(int i = A; i<=B; ++i){
map<int,int> mp;
ll pd = 1;
for(int x = i; x > 1; x /= s[x]) mp[s[x]]++;
for(pair<int,int> it: mp){
pd *= (powr(it.first, it.second+1) - 1ll)/(it.first-1ll);
}
tot += abs(2*i - pd);
}
printf("%lld", tot);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |