Submission #408923

#TimeUsernameProblemLanguageResultExecution timeMemory
408923iulia13Toys (CEOI18_toy)C++14
100 / 100
1984 ms4432 KiB
#include <iostream> #include <set> using namespace std; set <int> sol; void solve(int n, int x, int l) { if(n == 1) { sol.insert(x); return; } for(int a = 1; a * a <= n; a++) { if(n % a == 0) { if(a >= l) solve(n / a, x + a - 1, a); if(n / a >= l) solve(a, x + n / a - 1, n / a); } } } int main() { int n; cin >> n; solve(n, 0, 2); cout << sol.size() << '\n'; for(int x : sol) cout << x << " "; cout << '\n'; }
#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...