Submission #648431

#TimeUsernameProblemLanguageResultExecution timeMemory
648431ymmToys (CEOI18_toy)C++17
100 / 100
3069 ms90188 KiB
#include <bits/stdc++.h> #define Loop(x,l,r) for (ll x = (l); x < (ll)(r); ++x) #define LoopR(x,l,r) for (ll x = (r)-1; x >= (ll)(l); --x) typedef long long ll; typedef std::pair<int, int> pii; typedef std::pair<ll , ll > pll; using namespace std; set<int> solve(int n) { static map<int, set<int>> mem; if (n == 1) return {0}; if (mem.count(n)) return mem[n]; set<int> ans; for (int x = 2; x*x <= n; ++x) { if (n%x) continue; for (int y : solve(x)) ans.insert(y+n/x-1); for (int y : solve(n/x)) ans.insert(y+x-1); } ans.insert(n-1); mem[n] = ans; return ans; } int main() { cin.tie(0) -> sync_with_stdio(false); int n; cin >> n; auto ans = solve(n); cout << ans.size() << '\n'; for (int x : ans) cout << x << ' '; cout << '\n'; }
#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...