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 P(a) do{if(debug) cout<<a<<endl;} while(false)
#define H(a) P(#a<<": "<<a)
#define FR(i,a,b) for(int i = (a); i<(b); i++)
#define F(i,n) FR(i,0,n)
const int debug = 1;
using namespace std;
int n;
vector<vector<bool> > dp;
void f(int a){
if(!dp[a].empty()) return;
dp[a].assign(a+2,0);
dp[a][a-1] = true;
for(int i = 2; i*i<=a;i++) if(a%i == 0){
f(a/i);
F(j,a/i){
dp[a][j+(i-1)] = dp[a][j+(i-1)]||dp[a/i][j];
}
}
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
cin>>n;
dp.resize(n+5);
f(n);
cout<<count(dp[n].begin(),dp[n].end(),true)<<endl;
F(i,n+1){
if(dp[n][i]) cout<<i<<" ";
}
cout<<endl;
return 0;
}
# | 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... |