# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
131151 | Vardanyan | Toys (CEOI18_toy) | C++14 | 5025 ms | 72660 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>
using namespace std;
map<int,int> s;
map<pair<int,int>,int> mp;
vector<int> ans;
vector<int> divs[1000*1000+1];
void rec(int n,int sm){
if(mp[{n,sm}]) return;
mp[{n,sm}] = 1;
if(n == 1){
if(!s[sm]){
ans.push_back(sm);
s[sm] = 1;
}
return;
}
if(n>1000*1000 || divs[n].size() == 0){
for(int i = 1;i*i<=n;i++){
if(n%i) continue;
if(i>1){
rec(n/i,sm+i-1);
if(n<=1000000) divs[n].push_back(i);
}
int x = n/i;
rec(n/x,sm+x-1);
if(n<=1000000) divs[n].push_back(x);
}
}
else{
for(int i = 0;i<divs[n].size();i++){
int x = divs[n][i];
rec(n/x,sm+x-1);
}
}
}
int main(){
ios_base::sync_with_stdio(false);
int n;
cin>>n;
rec(n,0);
cout<<ans.size()<<endl;
sort(ans.begin(),ans.end());
for(int i = 0;i<ans.size();i++) cout<<ans[i]<<" ";
cout<<endl;
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... |