This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) x.begin(), x.end()
#define size(x) (int)x.size()
template<class S, class T>
bool chmin(S &a, const T &b) {
return a > b ? (a = b) == b : false;
}
template<class S, class T>
bool chmax(S &a, const T &b) {
return a < b ? (a = b) == b : false;
}
const int N = 1e5;
unordered_map<int, unordered_map<int, bool>> vis;
int sum = 0;
void solve(int n) {
sum += n - 1;
vis[sum][n] = true;
sum -= n - 1;
for (int d = 2; d * d <= n; ++d) {
if (n % d == 0) {
sum += d - 1;
if (!vis[sum + n / d - 1][n / d]) solve(n / d);
sum -= d - 1;
}
}
}
signed main() {
cin.tie(nullptr)->sync_with_stdio(false);
int n; cin >> n;
solve(n);
vector<int> res;
for (auto [i, j] : vis) {
res.push_back(i);
}
sort(all(res));
cout << size(res) << '\n';
for (auto i : res) cout << i << ' ';
}
# | 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... |