Submission #318132

#TimeUsernameProblemLanguageResultExecution timeMemory
318132nekiToys (CEOI18_toy)C++14
100 / 100
1675 ms5988 KiB
#include <bits/stdc++.h>
#define loop(i, a, b) for(long long i=a;i<b;i++)
#define pool(i, a, b) for(long long i=a-1;i>=b;i--)
#define fore(i, a) for(auto&& i:a)
#define fi first
#define se second
#define ps(a) push_back(a)
#define pb(a) pop_back(a)
#define sc scanf
#define vc vector
#define pa pair<ll, ll>
#define ll long long
#define lb lower_bound
#define ub upper_bound
#define all(a) a.begin(), a.end()
#define llmax LLONG_MAX/2
#define llmin -LLONG_MAX/2
using namespace std;
#define mn 100100
#define pa pair<ll, ll>
#define ld long double 
set<ll> solve(ll n, ll l){
    set<ll> ans;
    if(n<l) return ans;
    ans.insert(n-1);
    for(ll i=l;i * i <=n;i++){
        if(n%i==0){
            fore(v, solve(n/i, i)) ans.insert(i-1+v);
        }
    }
    return ans;
}
int main(){
    ll n;cin >> n;
    if(n==1){
        cout << 1 <<endl<<0<<endl;
        return 0;
    }
    auto ans=solve(n, 2);
    cout << ans.size()<<endl;
    fore(v, ans) cout << v <<" ";
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...