Submission #135867

#TimeUsernameProblemLanguageResultExecution timeMemory
135867MinnakhmetovToys (CEOI18_toy)C++14
100 / 100
874 ms4224 KiB
#include<bits/stdc++.h> using namespace std; #define ll long long #define all(aaa) aaa.begin(), aaa.end() vector<int> solve(int n, int last) { vector<int> v = { n - 1 }; for (int i = last; i * i <= n; i++) { if (n % i == 0) { auto q = solve(n / i, i); for (int x : q) { x += i - 1; v.push_back(x); } } } sort(all(v)); v.erase(unique(all(v)), v.end()); return v; } signed main() { #ifdef HOME freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif ios_base::sync_with_stdio(0); cin.tie(0); int n; cin >> n; auto v = solve(n, 2); cout << v.size() << "\n"; for (int x : v) cout << x << " "; 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...