Submission #949551

#TimeUsernameProblemLanguageResultExecution timeMemory
949551glebustimToys (CEOI18_toy)C++17
100 / 100
1484 ms82956 KiB
#include <bits/extc++.h> using namespace std; using namespace __gnu_pbds; #define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0) #define all(a) a.begin(), a.end() using ll = long long; using ld = long double; using pii = pair<int, int>; using vi = vector<int>; using oset = tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>; unordered_map<int, unordered_set<int>> g; unordered_set<int> solve(int x) { if (g.find(x) != g.end()) return g[x]; unordered_set<int> r; r.insert(x - 1); int y = 2; while (y * y <= x) { if (x % y == 0) { int z = x / y; unordered_set a = solve(y); for (int b: a) r.insert(b + z - 1); a = solve(z); for (int b: a) r.insert(b + y - 1); } ++y; } g[x] = r; return r; } int main() { fast; int n; cin >> n; unordered_set<int> a = solve(n); vi ans; for (int x: a) ans.push_back(x); sort(all(ans)); cout << ans.size() << '\n'; for (int x: ans) cout << x << ' '; }
#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...