Submission #1009176

#TimeUsernameProblemLanguageResultExecution timeMemory
1009176kebineToys (CEOI18_toy)C++17
100 / 100
325 ms4436 KiB
#include <bits/stdc++.h> #define int long long #define INF LLONG_MAX #define pii pair<int, int> using namespace std; set<int> sett; void pecah(int n, int prev, int nilai) { if (prev == INF) prev = 2; for (int i = prev; i * i <= n; i++) { if (n % i == 0) { int a = i, b = n / i; if (a > b) break; sett.insert(nilai + a + b - 2); pecah(b, a, nilai + a - 1); } } } int32_t main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n; cin >> n; pecah(n, INF, 0); 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...