#ifndef local
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("O3")
#endif
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
using ll = int;
using pll = pair<ll,ll>;
using str = string;
using ld = long double;
auto sd = std::chrono::high_resolution_clock::now().time_since_epoch().count();
mt19937 rnd(sd);
using ordset = tree<pll, null_type,less<>, rb_tree_tag,tree_order_statistics_node_update>;
set<multiset<ll>> e;
set<ll> answ;
void rec(multiset<ll> &u, set<ll>&u1) {
if (u.size()==1) {
answ.insert((*u.begin())-1);
return;
}
multiset<ll> new_= u;
set<ll> n1 = u1;
e.insert(new_);
ll ans = 0;
for (auto x: u){
ans += (x-1);
}
answ.insert(ans);
for (auto x1 : u1) {
for (auto x2 : u1) {
if (x2<x1)continue;
if (x1 == x2 && u.count(x1)<2){
continue;
}
bool p1 = false;
bool p2 = false;
bool p3 = false;
new_.erase(new_.find(x1));
if (new_.find(x1)==new_.end()) p1 = true;
new_.erase(new_.find(x2));
if (new_.find(x2)==new_.end()) p2 = true;
if (new_.find(x1*x2) == new_.end())p3= true;
new_.insert(x1*x2);
if (p1) n1.erase(x1);
if (p2) n1.erase(x2);
n1.insert(x1*x2);
if (e.find(new_)==e.end()) rec(new_, n1);
new_.erase(new_.find(x1*x2));
new_.insert(x1);
new_.insert(x2);
n1.insert(x1); n1.insert(x2);
if (p3) n1.erase(x1*x2);
}
}
}
void solve1() {
ll n;
cin >> n;
if (n == 1) {
cout << 1 << endl << 0 << endl;
return;
}
vector<int> pr;
ll d = 2;
while (d * d <= n) {
if (n % d == 0) {
pr.emplace_back(d);
n /= d;
}
else d++;
}
if (n > 1) pr.emplace_back(n);
multiset<ll>p;
set<ll> p1;
for (auto x:pr)p1.insert(x),p.insert(x);
rec(p,p1);
cout<<answ.size()<<endl;;
for (auto x: answ)cout<<x<<" ";
cout<<endl;
}
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
#ifdef local
freopen("in.txt", "r", stdin);
freopen("out.txt", "w", stdout);
#endif
ll t1 = 1;
//cin>>t1;
for (int _ = 0; _ < t1; ++_) solve1();
#ifdef local
printf_s("\n%.5f s", (double) clock() / CLOCKS_PER_SEC);
#endif
}
# | 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... |