Submission #599161

#TimeUsernameProblemLanguageResultExecution timeMemory
599161jiahngToys (CEOI18_toy)C++14
100 / 100
2200 ms91216 KiB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define ll int
typedef pair<int,int> pi;
typedef vector <int> vi;
typedef vector <pi> vpi;
typedef pair<pi, ll> pii;
typedef set <ll> si;
typedef long double ld;
#define f first
#define s second
#define mp make_pair
#define FOR(i,s,e) for(int i=s;i<=int(e);++i)
#define DEC(i,s,e) for(int i=s;i>=int(e);--i)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
#define aFOR(i,x) for (auto i: x)
#define mem(x,i) memset(x,i,sizeof x)
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define maxn 100010
#define INF (ll)(1e9+10)
#define MOD 1000000007
typedef pair <vi, int> pvi;
typedef pair <int,pi> ipi;
typedef vector <pii> vpii;
typedef pair <pi,pi> pipi;
int N;
set <int> dp[maxn];
int32_t main(){
    fast;
    cin >> N;
    vi v;
    FOR(i,2,sqrt(N)) if (N % i == 0){
        v.pb(i); v.pb(N / i);
    }        
    v.pb(N);
    
    sort(all(v)); v.erase(unique(all(v)), v.end());

    FOR(i,0,v.size()-1){
        dp[i].insert(v[i]-1);
        FOR(j,0,i-1) if (v[i] % v[j] == 0){
            aFOR(k,dp[j]) dp[i].insert(k+v[i] / v[j] - 1);
        }
    }
    cout << dp[v.size()-1].size() << '\n';
    aFOR(i,dp[v.size()-1]) cout << i << ' ';
}
#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...