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>
//#define int long long
#define pii pair<int, int>
#define ti3 tuple<int, int, int>
#define ti4 tuple<int, int, int, int>
// This is like my secret account; yes it's like that ~ Baek Jiheon, Feel Good (Secret Code)
using namespace std;
map<pii, int> off;
unordered_set<int> *dfs(int x, int s){
unordered_set<int> * curr_set = new unordered_set<int>();
curr_set->insert(x-1);
off[{x, s}] = 0;
for (int i = s; i*i<=x; i++){
if (x%i != 0) continue;
unordered_set<int> *child = dfs(x/i, i);
if (child->size() <= curr_set->size()){
int x1 = off[{x/i, i}];
int p = off[{x, s}];
for (auto j : *child){
curr_set->insert(j + x1 + i-1 - p);
}
delete child;
} else {
swap(child, curr_set);
swap(off[{x, s}], off[{x/i, i}]);
off[{x, s}] += i - 1;
int x1 = off[{x/i, i}];
int p = off[{x, s}];
for (auto j : *child){
curr_set->insert(j + x1 - p);
}
delete child;
}
}
return curr_set;
}
main(){
int x; cin >> x;
unordered_set<int> *ans = dfs(x, 2);
vector<int> ot;
int x2 = off[{x, 2}];
for (auto i : *ans){
ot.push_back(i + x2);
}
sort(ot.begin(), ot.end());
cout << ot.size() << '\n';
for (auto i : ot) cout << i << ' ';
}
Compilation message (stderr)
toy.cpp:37:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
37 | main(){
| ^~~~
# | 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... |