# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1088868 | Sunbae | Savrsen (COCI17_savrsen) | C++17 | 1088 ms | 39516 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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);
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |