Submission #893522

#TimeUsernameProblemLanguageResultExecution timeMemory
893522vjudge1Toys (CEOI18_toy)C++17
59 / 100
43 ms20056 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define sz(x) (int)x.size() #define all(x) x.begin(), x.end() const int N = (int)2e5 + 5; const int MAX = (int)1e8 + 5; const ll mod = (int)1e9 + 7; const ll inf = (int)(1e9) + 100; int n; vector<int> dv[N], ans; bitset<MAX> b; void rec(int c = 1, int sum = 0, int val = n) { if (c == n) { if (b[sum] == 0) ans.pb(sum); b[sum] = 1; return; } for (auto i : dv[val]) { rec(c * i, sum + (i - 1), val / i); } } void solve() { cin >> n; for (int i = 2; i <= n; i++) { for (int j = i; j <= n; j += i) { dv[j].pb(i); } } rec(); cout << sz(ans) << "\n"; sort(all(ans)); for (int i : ans) cout << i << " "; } signed main() { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); int T = 1; //cin >> T; while (T--) solve(); 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...