Submission #927865

#TimeUsernameProblemLanguageResultExecution timeMemory
927865RegulusToys (CEOI18_toy)C++17
19 / 100
1 ms500 KiB
#include <bits/stdc++.h> #define IO ios::sync_with_stdio(false);cin.tie(0); #define debug(x) cerr << #x << " = " << (x) << ' ' #define bug(x) cerr << (x) << ' ' #define endl cerr << '\n' #define all(v) (v).begin(), (v).end() #define SZ(v) (ll)(v).size() #define lowbit(x) (x)&-(x) #define pb emplace_back #define F first #define S second using namespace std; using ll = long long; using pll = pair<ll, ll>; const int Mxm = 10000; int prime[Mxm+5]; vector<int> p, v, ans; inline void sieve() { for (int i=2; i <= Mxm; ++i) prime[i] = i; for (int i=2; i <= Mxm; ++i) { if (prime[i] == i) p.pb(i); for (ll j : p) { if (i*j > Mxm) break; prime[i * j] = j; if (!(i % j)) break; } } } int main(void) { IO int n, i; cin >> n; if (n == 1) { cout << "1\n0\n"; exit(0); } sieve(); int cur = n, m = sqrt(n); for (i=2; i <= m; ++i) { while (!(cur % i)) { v.pb(i); cur /= i; } } if (cur > 1) v.pb(cur); for (int s=0; s < (1 << (SZ(v)-1)); ++s) { cur = v[0]; int sum = 0; for (int i=0; i < SZ(v)-1; ++i) { if ((s >> i) & 1) { sum += cur - 1; cur = 1; } cur *= v[i+1]; } sum += cur - 1; ans.pb(sum); } sort(all(ans)); ans.resize(unique(all(ans))-ans.begin()); cout << SZ(ans) << '\n'; for (int x : ans) cout << x << ' '; cout << '\n'; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...