Submission #86392

#TimeUsernameProblemLanguageResultExecution timeMemory
86392I_use_Brute_forceSavrsen (COCI17_savrsen)C++14
60 / 120
3042 ms1432 KiB
#include <bits/stdc++.h> #define pb push_back #define mp make_pair #define F first #define S second #define pii pair <int, int> #define sz(a) (int)(a.size()) #define resize(v) v.resize(unique(all(v)) - v.begin()); #define all(a) a.begin(), a.end() #define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it ++) using namespace std; void Fast_Read_Out() { ios_base::sync_with_stdio(0); cin.tie(), cout.tie(); } void Random() { unsigned int seed; asm("rdtsc" : "=A" (seed)); srand(seed); } unsigned int Time() { unsigned int time = clock() / 1000.00; return time; } const int inf = int(1e9) + 123; const int N = int(1e5) + 1; vector <int> v; int lp[N], d[N]; vector <int> pr; void Resheto() { for(int i = 2; i <= N - 1; i++) { if(lp[i] == 0) { lp[i] = i; pr.pb(i); } for(int j = 0; j < sz(pr) && pr[j] <= lp[i] && pr[j] * i * 1ll <= N - 1; j++) lp[pr[j] * i] = pr[j]; } } int Prime_Multipliers(int x) { int del = 2; int ans = 1; if(d[x]) return x - 1; while(x > 1) { if(d[x]) { ans += x; break; } while(x % del == 0) ans += del, x /= del, cout << del << ' '; del++; } return ans; } int main () { #ifdef JUDGE freopen("input.txt", "r", stdin); #endif Random(); Fast_Read_Out(); int a, b; cin >> a >> b; Resheto(); for(int i = 0; i < sz(pr); i++) d[pr[i]]++; long long res = 0; for(int i = a; i <= b; i++) { int ans = 0; for(int j = 2; j * j <= i; j++) { if(i % j == 0) { ans += j; int cur = i / j; if(i % cur == 0 && cur != j) ans += cur; } } if(ans == 0) { res += i - 1; continue; } ans++; res += abs(i - ans); } if(a == 1) res++; cout << res << endl; #ifdef JUDGE // cout << Time() << endl; #endif } // Easy Peasy Lemon Squeezy Sometimes it's the very people who no one imagines anything of who do the things no one can imagine.
#Verdict Execution timeMemoryGrader output
Fetching results...