Submission #942729

#TimeUsernameProblemLanguageResultExecution timeMemory
942729vjudge1Toys (CEOI18_toy)C++17
59 / 100
5063 ms1016 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(have == len-1){ int x = n / cur; if(n % cur != 0 or x <= 1) return; ans.insert(sum + x - 1); return; } long long atleast = cur * (1LL<<(len - have)); if(atleast > n) return; for(int x = 2; ; x++){ atleast = cur * x * (1LL<<(len - have - 1)); if(atleast > n) return; 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...