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>
#define int long long
using namespace std;
namespace std {
template <typename T> ostream &operator<<(ostream &out, const vector<T> &vec) {
out << "[";
for (int i = 0; i < (int)vec.size(); ++i) {
out << vec[i];
if (i + 1 < (int)vec.size())
out << ", ";
}
return out << "]";
}
} // namespace std
void dbg_out() { cout << endl; }
template <typename Head, typename... Tail> void dbg_out(Head H, Tail... T) {
cout << ' ' << H;
dbg_out(T...);
}
#ifdef DEBUG
#define dbg(...) cout << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
#else
#define dbg(...)
#endif
signed main(void) {
ios_base::sync_with_stdio(false);
cin.tie(0);
int n;
cin >> n;
vector<int> diviseurs;
for (int d = 1; d * d <= n; d++) {
if (n % d == 0) {
diviseurs.push_back(d);
if (d * d != n)
diviseurs.push_back(n / d);
}
}
sort(diviseurs.begin(), diviseurs.end());
auto getId = [&](int d) {
return lower_bound(diviseurs.begin(), diviseurs.end(), d) -
diviseurs.begin();
};
int nbDiviseurs = diviseurs.size();
vector<set<int>> possibilites(nbDiviseurs);
for (int i = 0; i < nbDiviseurs; ++i) {
int d = diviseurs[i];
possibilites[i].insert(d - 1);
for (int j = i + 1; j < nbDiviseurs; ++j)
if (diviseurs[j] % d == 0) {
int dd = diviseurs[j] / d;
int k = getId(dd);
if (k < i)
for (int p : possibilites[i])
for (int q : possibilites[k])
possibilites[j].insert(p + q);
}
}
cout << possibilites[nbDiviseurs - 1].size() << endl;
for (int x : possibilites.back())
cout << x << ' ';
cout << endl;
}
# | 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... |