제출 #943142

#제출 시각아이디문제언어결과실행 시간메모리
943142vjudge1Toys (CEOI18_toy)C++14
0 / 100
1 ms428 KiB
#include <bits/stdc++.h>

using namespace std;
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define int long long

unordered_map<int, map<int, bool> > mp;

vector<int> ans;
int sum = 0;
void f(int n){
    if(mp[n].count(sum)) return;
    mp[n][sum] = true;
    if(n == 1){
        ans.push_back(sum);
        return;
    }
    for(int d = 1; d * d <= n; d++){
        if(n % d == 0){
            int x = n / d;
            if(x != 1){
                sum = sum + x - 1;
                f(n / x);
                sum = sum - x + 1;
            }
            if(n / d != d){
                x = n / d;
                sum = sum + x - 1;
                f(n / x);
                sum = sum - x + 1;
            }
        }
    }
    
}


signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int n; cin >> n;
    f(n);
    sort(all(ans));
    cout << ans.size() << '\n';
    for(auto x : ans) cout << x << ' ';
    
    
    
    return 0;
}

#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...