Submission #942801

#TimeUsernameProblemLanguageResultExecution timeMemory
942801vjudge1Toys (CEOI18_toy)C++17
19 / 100
1 ms348 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; bool vis[N]; int sum = 0; void solve(int n) { if (vis[sum]) return; sum += n - 1; vis[sum] = true; sum -= n - 1; for (int d = 2; d * d <= n; ++d) { if (n % d == 0) { sum += 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 (int i = 0; i < n; ++i) { if (vis[i]) res.push_back(i); } 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...