Submission #579178

#TimeUsernameProblemLanguageResultExecution timeMemory
579178webToys (CEOI18_toy)C++17
100 / 100
1707 ms4388 KiB
#include <iostream> #include <vector> #include <string> #include <set> #include <math.h> using namespace std; set<long long> numToys; void recursiveCalc( long long n, long long numUsedAlready, long long maxN) { if(n==1) { numToys.insert(numUsedAlready); return; } if(n>1) numToys.insert(numUsedAlready+(n-1)); for(int i = 1; i<=min(maxN,static_cast<long long>(ceil(sqrt(n))));++i) { if(n%(i+1) == 0) { recursiveCalc( n/(i+1), numUsedAlready + i, i); } } } int main() { long long n; cin>>n; recursiveCalc( n, 0, n+1); cout<<numToys.size()<<endl; for(auto el:numToys) cout<<el<<" "; 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...