Submission #116694

#TimeUsernameProblemLanguageResultExecution timeMemory
116694johuthaToys (CEOI18_toy)C++14
100 / 100
3198 ms86600 KiB
#include <iostream> #include <vector> #include <set> #include <algorithm> #define int int64_t using namespace std; vector<int> getdivs(int n) { vector<int> res; for (int d = 2; d*d <= n; d++) { if (n % d == 0) { res.push_back(d); if (d * d != n) res.push_back(n / d); } } res.push_back(n); sort(res.begin(), res.end()); return res; } signed main() { int n; cin >> n; vector<int> divs = getdivs(n); int dc = divs.size(); vector<set<int>> res(dc); for (int f = 0; f < dc; f++) { int fdiv = divs[f]; for (int sd = 0; sd < f; sd++) { int sdiv = divs[sd]; if (fdiv % sdiv == 0) { int od = fdiv / sdiv; for (int nr : res[sd]) { res[f].insert(nr + od - 1); } } } res[f].insert(fdiv - 1); } cout << res[dc - 1].size() << "\n"; for (int i : res[dc - 1]) cout << i << " "; 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...