# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
70889 | georgerapeanu | Toys (CEOI18_toy) | C++11 | 1798 ms | 110288 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |