Submission #942721

#TimeUsernameProblemLanguageResultExecution timeMemory
942721vjudge1Toys (CEOI18_toy)C++17
59 / 100
5080 ms716 KiB
#include <bits/stdc++.h>

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




signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int n; cin >> n;
    
    vector<int> p;
    set<int> ans;
    ans.insert(n-1);
    for(int len = 2; len <= 33; len++){
        function<void(int, int, int)> f=[&](int cur, int have, int sum){
                if(have == len){
                   if(cur == n) ans.insert(sum);
                   return; 
                }
                if(cur * (1<<(len - have)) > n) return;
                for(int x = 2; cur * x <= n; x++){
                    f(cur*x, have + 1, sum + x - 1);
                }
        };
        f(1, 0, 0);
    }
    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...