Submission #70889

#TimeUsernameProblemLanguageResultExecution timeMemory
70889georgerapeanuToys (CEOI18_toy)C++11
100 / 100
1798 ms110288 KiB
#include <cstdio> #include <set> #include <algorithm> #include <vector> using namespace std; int N; vector<int> divisors; vector< vector<int> > sums; vector<int> ans; int main() { fscanf(stdin,"%d",&N); for(int d = 2;1LL * d * d <= N;d++){ if(N % d == 0){ divisors.push_back(d); if(d * d != N){ divisors.push_back(N / d); } } } divisors.push_back(N); sort(divisors.begin(),divisors.end()); sums.resize(divisors.size()); for(int i = 0;i < (int)divisors.size();i++){ sums[i].push_back(divisors[i] - 1); int st = 0; for(int j = i - 1;j >= 0;j--){ while(st < i - 1 && 1LL * divisors[j] * divisors[st] < divisors[i]){ st++; } if(divisors[j] * divisors[st] != divisors[i]){ continue; } for(auto it:sums[st]){ sums[i].push_back(it + divisors[j] - 1); } } sort(sums[i].begin(),sums[i].end()); sums[i].resize(unique(sums[i].begin(),sums[i].end()) - sums[i].begin()); } fprintf(stdout,"%d\n",(int)sums.back().size()); for(auto it:sums.back()){ fprintf(stdout,"%d ",it); } return 0; }

Compilation message (stderr)

toy.cpp: In function 'int main()':
toy.cpp:16:11: warning: ignoring return value of 'int fscanf(FILE*, const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     fscanf(stdin,"%d",&N);
     ~~~~~~^~~~~~~~~~~~~~~
#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...