Submission #424755

#TimeUsernameProblemLanguageResultExecution timeMemory
424755Rouge_HugoToys (CEOI18_toy)C++14
39 / 100
145 ms81904 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...