제출 #1236615

#제출 시각아이디문제언어결과실행 시간메모리
1236615yassiaToys (CEOI18_toy)C++20
59 / 100
5096 ms98856 KiB
#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 = long long;
#define int ll
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) {
    if (u.size()==1) {
        answ.insert((*u.begin())-1);
        return;
    }
    multiset<ll> new_= u;
    e.insert(new_);
    ll ans = 0;
    for (auto x: u){
        ans += (x-1);
    }
    answ.insert(ans);
    for (auto x1 : u) {
        for (auto x2 : u) {
            if (x1 == x2 && u.count(x1)<2){
                continue;
            }
            new_.erase(new_.find(x1));
            new_.erase(new_.find(x2));
            new_.insert(x1*x2);

            if (e.find(new_)==e.end()) rec(new_);
            new_.erase(new_.find(x1*x2));
            new_.insert(x1);
            new_.insert(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;
    for (auto x:pr)p.insert(x);
    rec(p);
    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 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...