# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
969638 | RandomUser | Savrsen (COCI17_savrsen) | C++17 | 1250 ms | 49484 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
//#define int long long
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int mod = 1e9 + 7;
const int LOG = 20;
const int maxn = 1e7 + 5;
const double eps = 1e-9;
bool sieve[maxn+1];
int mpf[maxn+1];
ll exp(ll a, ll b) {
ll ans = 1;
while(b) {
if(b & 1) ans = ans * a;
a = a * a;
b /= 2;
}
return ans;
}
int32_t main() {
sieve[1] = 1;
for(int i=2; i<=maxn; i++) {
if(sieve[i]) continue;
mpf[i] = i;
for(int j=2*i; j<=maxn; j+=i) {
sieve[j] = i;
mpf[j] = i;
}
}
int l, r;
ll ans = 0;
cin >> l >> r;
for(int i=l; i<=r; i++) {
map<int, int> cnt;
int x = i;
while(x > 1) {
cnt[mpf[x]]++;
x /= mpf[x];
}
ll div = 1;
for(auto &[d, c] : cnt)
div *= ((exp(d, c+1) - 1) / (d - 1));
ans += abs((ll)i - (div - i));
}
cout << ans << '\n';
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |