# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1094993 | alexander707070 | Toys (CEOI18_toy) | C++14 | 98 ms | 262144 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<bits/stdc++.h>
#define MAXN 5007
using namespace std;
int n;
vector<int> dels;
vector<int> sums[MAXN][MAXN];
unordered_map<int,int> pos;
set<int> ans;
vector<int> ff(int d,int mins){
if(mins>d)return {dels[d]-1};
if(dels[d]%dels[mins]!=0)return ff(d,mins+1);
if(!sums[d][mins].empty())return sums[d][mins];
sums[d][mins] = ff(d,mins+1);
vector<int> s=ff(pos[dels[d]/dels[mins]],mins);
for(int i:s){
sums[d][mins].push_back(i+dels[mins]-1);
}
return sums[d][mins];
}
int main(){
cin>>n;
for(int i=1;i*i<=n;i++){
if(n%i!=0)continue;
dels.push_back(i);
if(i!=n/i)dels.push_back(n/i);
}
sort(dels.begin(),dels.end());
for(int i=0;i<dels.size();i++){
pos[dels[i]]=i;
}
vector<int> w=ff(dels.size()-1,1);
for(int i:w)ans.insert(i);
cout<<ans.size()<<"\n";
for(int i:ans){
cout<<i<<" ";
}
cout<<"\n";
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... |