Submission #942907

#TimeUsernameProblemLanguageResultExecution timeMemory
942907vjudge1Toys (CEOI18_toy)C++14
79 / 100
5052 ms3372 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 signed main(){ ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); auto split=[&](int n){ map<int, int> mp; mp[n-1] = 1; vector<int> p; for(int i = 2; i * i <= n; i++){ if(n%i == 0){ p.push_back(i); if(n / i != i) p.push_back(n / i); } } sort(all(p)); function<void(int, int, int, int)> f=[&](int cur, int have, int sum, int last){ if(cur > n) return; if(cur == n){ mp[sum] = 1; return; } for(int id = last; id < (int)p.size(); id++){ int x = p[id]; if(cur * x > n) break; f(cur*x, have + 1, sum + x - 1, id); } }; f(1, 0, 0, 0); set<int> ans; for(auto x : mp) ans.insert(x.ff); return ans; }; int n; cin >> n; /* vector<pair<int, int>> factors; for(int i = 2; i * i <= n; i++){ pair<int, int> s = {i, 0}; while(n > 0 && n % i == 0){ n/= i; s.ss++; } if(s.ss > 0) factors.push_back(s); } */ set<int> st = split(n); cout << st.size() << '\n'; for(auto x : st){ 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...