Submission #604677

#TimeUsernameProblemLanguageResultExecution timeMemory
604677pakhomoveeToys (CEOI18_toy)C++17
100 / 100
1716 ms66024 KiB
#include <iostream> #include <vector> #include <random> #include <algorithm> #include <cassert> #include <cstring> using namespace std; #define int long long vector<int> ans; void rec(int x, int mx, int c) { if (x == 1) { ans.push_back(c); return; } int j = 1; while (j * j <= x) { if (x % j == 0) { if (mx >= j && j != 1) { rec(x / j, j, c + j - 1); } if (mx >= x / j) { rec(j, j, c + x / j - 1); } } ++j; } } int32_t main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n; cin >> n; rec(n, n + 1, 0); sort(ans.begin(), ans.end()); ans.resize(unique(ans.begin(), ans.end()) - ans.begin()); cout << ans.size() << '\n'; for (int i : ans) cout << i << ' '; }
#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...