Submission #290755

#TimeUsernameProblemLanguageResultExecution timeMemory
290755groeneprofToys (CEOI18_toy)C++14
59 / 100
151 ms262148 KiB
#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 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...