(UPD: 2024-12-04 14:48 UTC) Judge is not working due to Cloudflare incident. (URL) We can do nothing about it, sorry. After the incident is resolved, we will grade all submissions.

제출 #1119709

#제출 시각아이디문제언어결과실행 시간메모리
1119709vjudge1Toys (CEOI18_toy)C++17
100 / 100
447 ms4424 KiB
#include <bits/stdc++.h> #define pb push_back #define sz(x) (int)x.size() #define all(x) x.begin(), x.end() #define f first #define s second using namespace std; using ll = long long; using pii = pair <int, int>; const int N = 2e5 + 5; int n; vector <int> p; set <ll> st; void solve(int x, int i, ll sum) { if (x == 1) { st.insert(sum); return; } while (i >= 0 && x % p[i]) i--; if (i < 0) return; solve(x, i - 1, sum); solve(x / p[i], i, sum + p[i] - 1); } int main() { ios :: sync_with_stdio(0); cin.tie(0); cin >> n; for (int i = 2; i * i <= n; ++i) { if (n % i == 0) { p.pb(i); if (i * i != n) p.pb(n / i); } } p.pb(n); sort(all(p)); solve(n, sz(p) - 1, 0); cout << sz(st) << '\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...