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;
#define hash long long
unordered_set<hash> hset;
hash get(int n, int sum){
hash res = (hash) n * 1e9l + sum;
return res;
}
void backtrack(int n, int sum){
hash now = get(n, sum);
if(hset.find(now) != hset.end())
return;
hset.insert(now);
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(hash sum : hset)
if(sum / (hash)1e9l == 1ll)
unique.insert(sum % (hash)1e9);
cout << unique.size() << '\n';
for(int it : unique)
cout << it << ' ';
}
# | 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... |