Submission #260581

#TimeUsernameProblemLanguageResultExecution timeMemory
260581stefantagaToys (CEOI18_toy)C++14
59 / 100
5077 ms980 KiB
#include <bits/stdc++.h> using namespace std; int valori[1000005],q1,n,q,divi[1000005],solutii[1000005],fin; map <int,int> m; void back1(int nr,int suma,int prod) { if (prod==n) { m[suma-nr]=1; return; } int i; for (i=1;i<=q;i++) { if ((n/prod)%divi[i]==0&&solutii[nr-1]<=divi[i]) { solutii[nr]=divi[i]; back1(nr+1,suma+divi[i],prod*divi[i]); } } } int i; int main() { #ifdef HOME ifstream cin("date.in"); ofstream cout("date.out"); #endif // HOME cin>>n; if (n==1) { cout<<"1"<<'\n'; cout<<"0"; return 0; } for (i=1;i*i<=n;i++) { if (n%i==0) { if (i!=1) { divi[++q]=i; } divi[++q]=n/i; } } back1(0,0,1); for (auto ind:m) { solutii[++fin]=ind.first; } cout<<fin<<'\n'; for (i=1;i<=fin;i++) { cout<<solutii[i]<<" "; } 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...