# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
729565 | Baytoro | Toys (CEOI18_toy) | C++17 | 2372 ms | 4312 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;
#define ios ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fr first
#define sc second
#define endl '\n'
#define ll long long
#define int long long
void fopn(string name){
freopen((name+".in").c_str(),"r",stdin);
freopen((name+".out").c_str(),"w",stdout);
}
const ll INF=1e18,mod=1e9+9,N=2e5+5;
set<int> st;
void calc(int x, int sum, int pre){
if(x==1){
st.insert(sum);
return;
}
for(int i=1;i<=sqrt(x);i++){
if(x%i==0){
if(i>=pre && i!=1) calc(x/i, sum+i-1,i);
if(x/i>=pre && x/i!=i) calc(i, sum+x/i-1,x/i);
}
}
}
void solve(){
int x;cin>>x;
calc(x,0,1);
cout<<st.size()<<endl;
for(auto it: st)
cout<<it<<' ';
}
main(){
//fopn("friendcross");
ios;
int T=1;
//cin>>T;
for(int i=1;i<=T;i++){
//cout<<"Case #"<<i<<": ";
solve();
}
}
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... |