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;
unordered_map<int, set<int>> dp;
void solve(int n){
vector<int> div;
for(int i = 2; i * i <= n; ++i){
if(n % i == 0){
div.push_back(i);
if(i * i != n)
div.push_back(n / i);
}
}
div.push_back(n);
for(int d: div){
int nd = n / d;
for(int x: dp[n])
dp[nd].insert(x + d - 1);
}
}
int main(){
ios::sync_with_stdio(false);
cin.tie(NULL);
int n;
cin >> n;
vector<int> div;
for(int i = 2; i * i <= n; ++i){
if(n % i == 0){
div.push_back(i);
if(i * i != n)
div.push_back(n / i);
}
}
div.push_back(n);
sort(div.begin(), div.end());
reverse(div.begin(), div.end());
dp[n].insert(0);
for(int d: div)
solve(d);
cout << dp[1].size() << "\n";
for(int x: dp[1])
cout << x << " ";
cout << "\n";
}
# | 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... |