# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
536874 | chicken337 | Toys (CEOI18_toy) | C++14 | 5038 ms | 42944 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
set<pair<int, int>> vis;
void backtrack(int n, int sum){
if(vis.find({n, sum}) != vis.end())
return;
vis.insert({n, sum});
for(int k = 2; k <= sqrt(n); k ++)
if(n % k == 0)
backtrack(n / k, sum + k - 1),
backtrack(k, sum + (n/k) - 1);
if(n != 1)
backtrack(1, sum + n - 1);
}
signed main(){
ios::sync_with_stdio(0);
cin.tie(0);
int n; cin >> n;
backtrack(n, 0);
set<int> unique;
for(auto &[num, sum] : vis)
if(num == 1)
unique.insert(sum);
cout << unique.size() << '\n';
for(int it : unique)
cout << it << ' ';
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |