# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
558653 | 2022-05-07T21:45:29 Z | aryan12 | Toys (CEOI18_toy) | C++17 | 1 ms | 212 KB |
#include <bits/stdc++.h> using namespace std; #define int long long mt19937_64 RNG(chrono::steady_clock::now().time_since_epoch().count()); set<int> ans; vector<int> divisors; // <= 30 vector<int> suffix_divisors; void func(int idx, int num, int sum) { // cout << "idx = " << idx << ", num = " << num << ", sum = " << sum << "\n"; if(idx == divisors.size()) { return; } ans.insert(sum + num - 1); if(num % divisors[idx] == 0 && num / divisors[idx] >= divisors[idx]) { func(idx, num / divisors[idx], sum + divisors[idx] - 1); } func(idx + 1, num, sum); } void Solve() { int n; cin >> n; int x = n; for(int i = 2; i <= sqrt(x); i++) { if(x % i == 0) { divisors.push_back(i); } } if(x != 1) { divisors.push_back(x); } sort(divisors.begin(), divisors.end()); // for(int i = 0; i < divisors.size(); i++) // { // cout << divisors[i] << " "; // } // cout << "\n"; // x = divisors.size(); // suffix_divisors.resize(x); // suffix_divisors[x - 1] = divisors[x - 1]; // for(int i = divisors.size() - 2; i >= 0; i--) // { // suffix_divisors[i] = suffix_divisors[i + 1] + divisors[i]; // } func(0, n, 0); cout << ans.size() << "\n"; for(auto i: ans) { cout << i << " "; } cout << "\n"; } int32_t main() { auto begin = std::chrono::high_resolution_clock::now(); ios_base::sync_with_stdio(0); cin.tie(0); int t = 1; // cin >> t; for(int i = 1; i <= t; i++) { //cout << "Case #" << i << ": "; Solve(); } auto end = std::chrono::high_resolution_clock::now(); auto elapsed = std::chrono::duration_cast<std::chrono::nanoseconds>(end - begin); cerr << "Time measured: " << elapsed.count() * 1e-9 << " seconds.\n"; return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 212 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 212 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 212 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 212 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 212 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |