제출 #448155

#제출 시각아이디문제언어결과실행 시간메모리
448155CalicoToys (CEOI18_toy)C++17
79 / 100
5065 ms3940 KiB
#include <bits/extc++.h> using namespace std; __gnu_pbds::gp_hash_table<int, bool> ans; __gnu_pbds::gp_hash_table<int, vector<int>> dvs; void brute(int n, int sum, int prv) { ans[n+sum-1] = 1; for (int i: dvs[n]) { if (i < prv) break; brute(n/i, sum+i-1, i); } } signed main() { ios::sync_with_stdio(0); cin.tie(0); int n; cin >> n; vector<int> dv; for (int i = 1; i*i <= n; i++) { if (n % i == 0) { int a = i, b = n/i; dv.push_back(a); if (a != b) dv.push_back(b); } } for (int j: dv) { for (int i = 1; i*i <= j; i++) { if (j % i == 0) { int a = i, b = j/i; if (a != 1 && a != j) dvs[j].push_back(a); if (a != b && b != 1 && b != j) dvs[j].push_back(b); } } sort(dvs[j].begin(), dvs[j].end(), greater<int>()); } brute(n, 0, 0); vector<int> anss; for (auto [u, v]: ans) { anss.push_back(u); } sort(anss.begin(), anss.end()); cout << anss.size() << '\n'; for (int i: anss) cout << i << ' '; 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...