제출 #430523

#제출 시각아이디문제언어결과실행 시간메모리
430523PetyToys (CEOI18_toy)C++14
59 / 100
837 ms1728 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long int n; set<int>ans; int nr, d; vector<int>Div; int st[40]; void backt (int prod, int k, int sum) { ans.insert(sum + n / prod - 1); if (prod == n) return; for (int i = st[k - 1]; i < d; i++) { ll x = prod * Div[i]; if (x > n) break; if (n % x== 0) { st[k] = i; backt(x, k + 1, sum + Div[i] - 1); } } } int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> n; for (int i = 1; i * i <= n; i++) { if (n % i == 0) { if (i > 1) Div.push_back(i); if (i != n / i) Div.push_back(n/i); } } d = Div.size(); sort(Div.begin(), Div.end()); backt(1, 1, 0); cout << ans.size() << "\n"; for (auto it : ans) cout << it << " "; 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...