#include <bits/stdc++.h>
using namespace std;
template <class A, class B>
bool maximize(A &a, const B b) {
if (a < b) {
a = b;
return true;
} return false;
}
template <class A, class B>
bool minimize(A &a, const B b) {
if (a > b) {
a = b;
return true;
} return false;
}
#define pb push_back
#define FOR(i, a, b) for(int i = a; i <= (int)b; i++)
#define FORD(i, a, b) for(int i = a; i >= (int)b; i--)
#define fi first
#define se second
#define ALL(A) A.begin(), A.end()
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef long long ll;
const int N = 3e5 + 5;
const int oo = 2e9 + 29032008;
const ll INF = 1e18 + 29032008;
int n;
map <pair <int, int>, bool> dp;
void solve() {
cin >> n;
queue <pair <int, int>> que;
que.push({1, 0});
while (!que.empty()) {
int tich = que.front().fi, len = que.front().se;
que.pop();
if (dp[{tich, len}]) continue;
int rem = n / tich;
for (int i = 1; i * i <= rem; i++) if (rem % i == 0) {
if (i != 1) {
if (dp[{tich * i, len + i - 1}] == 0) {
que.push({tich * i, len + i - 1});
}
}
if (rem / i != i) {
if (dp[{tich * rem / i, len + rem / i - 1}] == 0) {
que.push({tich * rem / i, len + rem / i - 1});
}
}
}
}
int res = 0;
for (auto &x : dp) if (x.fi.fi == n) res++;
cout << res << "\n";
for (auto &x : dp) if (x.fi.fi == n) cout << x.fi.se << " ";
}
signed main() {
ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define ko "kieuoanh"
if (fopen(ko".inp", "r")) {
freopen(ko".inp", "r", stdin);
freopen(ko".out", "w", stdout);
}
int NTEST = 1; // cin >> NTEST;
while (NTEST--) solve();
cerr << "\n[Time Elapsed] " << 0.001 * clock() << "s\n";
return 0;
}
Compilation message (stderr)
toy.cpp: In function 'int main()':
toy.cpp:67:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
67 | freopen(ko".inp", "r", stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
toy.cpp:68:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
68 | freopen(ko".out", "w", stdout);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |