Submission #1009128

#TimeUsernameProblemLanguageResultExecution timeMemory
1009128makanhuliaToys (CEOI18_toy)C++17
59 / 100
5017 ms1056 KiB
#include <bits/stdc++.h> #define int long long #define INF LLONG_MAX #define pii pair<int, int> using namespace std; void pecah(int n, int prev, int nilai, set<int> &sett) { vector<int> factors; for (int i = 2; i * i <= n; i++) { if (n % i == 0) factors.push_back(i); } for (auto factor : factors) { int a = factor, b = n / factor; if (a > b) break; sett.insert(nilai + a + b - 2); pecah(b, a, nilai + a - 1, sett); } } int32_t main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n; cin >> n; set<int> sett; pecah(n, INF, 0, sett); cout << sett.size() + 1 << endl; for (auto s : sett) cout << s << " "; cout << n - 1 << endl; 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...