Submission #533818

#TimeUsernameProblemLanguageResultExecution timeMemory
533818groshiToys (CEOI18_toy)C++17
100 / 100
771 ms4424 KiB
#include<iostream> #include<vector> #include<algorithm> #include<set> using namespace std; vector<int> Q; set<int> wynik; set<int>::iterator it; void rozklad(int n) { for(int i=1;i*i<=n;i++) if(n%i==0) { if(i*i==n) Q.push_back(i); else{ Q.push_back(i); Q.push_back(n/i); } } sort(Q.begin(),Q.end()); } void oblicz(int n,int gdzie,int suma) { if(n==1) { wynik.insert(suma); return; } for(int i=gdzie;i>0;i--) { if(n%Q[i]==0) oblicz(n/Q[i],i,suma+Q[i]-1); } } int main() { cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0); int n; cin>>n; rozklad(n); oblicz(n,Q.size()-1,0); cout<<wynik.size()<<"\n"; for(it=wynik.begin();it!=wynik.end();it++) cout<<*it<<" "; 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...