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 ll long long
#define fi first
#define se second
#define pb push_back
using namespace std;
int n;const int N=10090;
int y[N];
vector<int>vis[N];
vector<int>v,vv;
void d(int sum,int p)
{
if(sum>n)return ;
if(p>n)return ;
if(vis[p][sum])return;
vis[p][sum]=1;
if(p==1)
{
y[sum]=1;return;
}
for(auto it:v)
{
if(p%it)continue;
d(sum+it-1,p/it);
}
}
int main()
{
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
cin>>n;
for(int i=2;i<=n;i++)
{
if(n%i)continue;
v.pb(i);
for(int j=0;j<=n+1;j++)vis[i].pb(0);
}
for(int j=0;j<=n+1;j++)vis[1].pb(0);
d(0,n);
for(int i=0;i<=n;i++)
{
if(y[i])vv.pb(i);
}
cout<<vv.size()<<endl;
for(auto it:vv)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... |