# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
536881 | chicken337 | Toys (CEOI18_toy) | C++14 | 5063 ms | 65960 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 ++){
int div = n / k;
if((div * k) == n)
backtrack(div, sum + 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... |