# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
466896 | 2021-08-21T02:23:11 Z | XBoRickie | Savrsen (COCI17_savrsen) | C++11 | 5 ms | 588 KB |
#include <bits/stdc++.h> using namespace std; // Typedef typedef string str; typedef long double ld; typedef long long int int64; typedef unsigned long long int uint64; typedef std::pair<int, int> PII; typedef std::pair<int64, int64> PLL; typedef std::vector<int> VI; typedef std::vector<long long> VLL; // Define For-loop #define FOR(i, j, k, in) for (int i = (j); i < (k) ; i += (in)) #define FORW(i, j, k, in) for (int i = (j); i <= (k); i += (in)) #define RFOR(i, j, k, in) for (int i = (j); i >= (k); i -= (in)) // Define Data structure func #define all(cont) cont.begin(), cont.end() #define rall(cont) cont.rbegin(), cont.rend() #define sz(cont) int((cont).size()) #define pb push_back #define mp make_pair #define fi first #define se second // Define number #define IINF 0x3f3f3f3f #define LLINF 1000111000111000111LL #define PI 3.1415926535897932384626433832795 // Other #define lend '\n' #define hardio(name) freopen(name".inp","r",stdin), freopen(name".out","w",stdout); void FastIO() { std::ios_base::sync_with_stdio(false); std::cin.tie(NULL); cin.exceptions(cin.failbit); srand(time(NULL)); } const int MOD = 1e9 + 7, MOD2 = 1e9 + 9; // ====================================================================== int l, r; vector<int> pr; void sieve(int N = sqrt(1e9)) { int lp[N + 12] = {}; FORW(i, 2, N, 1) { if (lp[i] == 0) lp[i] = i, pr.pb(i); for(int j = 0; j < pr.size() && pr[j] <= lp[i] && 1ll*i*pr[j] <= N; ++j) lp[i * pr[j]] = pr[j]; } } int sum[10000007] = {}; int Abs(int n) { return (n^(n>>31)) - (n>>31); } int main(int argc, char* argv[]) { FastIO(); #ifndef ONLINE_JUDGE hardio("input"); #endif cin >> l >> r; sieve(r); FORW(i, 1, r, 1) sum[i] = 1; for(int p : pr) { int64 sm = 1; for(int64 x = p; x <= r; x *= p) { for(int64 y = x; y <= r; y += x) { sum[y] /= sm; sum[y] *= (sm + x); } sm += x; } } int64 ans = 0; FORW(i, l, r, 1) ans += Abs(2 * i - sum[i]); cout << ans << endl; return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 4 ms | 588 KB | Execution killed with signal 6 |
2 | Runtime error | 5 ms | 588 KB | Execution killed with signal 6 |
3 | Runtime error | 4 ms | 588 KB | Execution killed with signal 6 |
4 | Runtime error | 4 ms | 528 KB | Execution killed with signal 6 |
5 | Runtime error | 4 ms | 588 KB | Execution killed with signal 6 |
6 | Runtime error | 4 ms | 588 KB | Execution killed with signal 6 |
7 | Runtime error | 4 ms | 588 KB | Execution killed with signal 6 |
8 | Runtime error | 4 ms | 588 KB | Execution killed with signal 6 |