# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|
424739 | | A_D | Toys (CEOI18_toy) | C++14 | | 201 ms | 30788 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 int long long
#define ii pair<int,int>
#define F first
#define S second
#define du long double
using namespace std;
const int N=1e5+100;
vector<int> vec[N];
map<ii,bool>mp;
set<int> st;
void bc(int n,int sum)
{
if(mp[{n,sum}])return;
mp[{n,sum}]=1;
if(n==1){
st.insert(sum);
return;
}
for(auto x:vec[n]){
bc(n/x,sum+x-1);
}
}
void solve()
{
int n;
cin>>n;
for(int i=2;i<=n;i++){
for(int j=1;j*j<=i;j++){
if(i%j==0){
if(j!=1)vec[i].push_back(j);
if(j*j!=i)vec[i].push_back(i/j);
}
}
}
bc(n,0);
cout<<st.size()<<endl;
for(auto x:st)cout<<x<<" ";
}
main()
{
int t=1;
//cin>>t;
while(t--)solve();
}
Compilation message (stderr)
toy.cpp:40:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
40 | main()
| ^~~~
# | 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... |