제출 #1128832

#제출 시각아이디문제언어결과실행 시간메모리
1128832Alihan_8Toys (CEOI18_toy)C++20
100 / 100
793 ms4384 KiB
#include <bits/stdc++.h> using namespace std; signed main(){ int n; cin >> n; if ( n == 1 ) return cout << "1\n0\n", 0; vector <int> d{n}; for ( int i = 2; i * i <= n; i++ ){ if ( n % i == 0 ){ d.push_back(i); if ( i * i != n ) d.push_back(n / i); } } sort(d.begin(), d.end()); set <int> st; auto dfs = [&](auto dfs, int x, int s, int i) -> void{ if ( x == 1 ){ st.insert(s); return; } while ( i >= 0 && x % d[i] ) i--; if ( i < 0 ) return; dfs(dfs, x / d[i], s + d[i] - 1, i); dfs(dfs, x, s, i - 1); }; dfs(dfs, n, 0, d.size() - 1); cout << st.size() << '\n'; for ( auto &x: st ) cout << x << ' '; cout << '\n'; }
#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...