Submission #942824

#TimeUsernameProblemLanguageResultExecution timeMemory
942824vjudge1Toys (CEOI18_toy)C++17
19 / 100
1 ms460 KiB
#include <bits/stdc++.h> using namespace std; //#define int long long #define all(x) x.begin(), x.end() #define size(x) (int)x.size() template<class S, class T> bool chmin(S &a, const T &b) { return a > b ? (a = b) == b : false; } template<class S, class T> bool chmax(S &a, const T &b) { return a < b ? (a = b) == b : false; } const int N = 1e5; unordered_map<int, bool> vis; int sum = 0; void solve(int n) { sum += n - 1; vis[sum] = true; sum -= n - 1; for (int d = 2; d * d <= n; ++d) { if (n % d == 0) { sum += d - 1; if (!vis[sum + n / d - 1]) solve(n / d); sum -= d - 1; } } } signed main() { cin.tie(nullptr)->sync_with_stdio(false); int n; cin >> n; solve(n); vector<int> res; for (auto [i, v] : vis) { res.push_back(i); } sort(all(res)); cout << size(res) << '\n'; for (auto i : res) cout << i << ' '; }
#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...