Submission #1236832

#TimeUsernameProblemLanguageResultExecution timeMemory
1236832yassiaToys (CEOI18_toy)C++20
100 / 100
2891 ms86536 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 = 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>;
struct pair_hsh {
    template <class t1, class t2>
    size_t operator()(const pair<t1, t2> &pp)const {
        auto h1 = hash<t1>{}(pp.first);
        auto h2 = hash<t2>{}(pp.second);
        return h1^(h2<<1);
    }
};

map<ll,set<ll>> c;
ll n1 = 0;
set<ll> answ;

void solve1() {
    ll n;
    cin >> n;
    vector<ll> divs;
    for (int d = 1; d*d<=n;d++){
        if ((n / d)*d==n) {
            divs.emplace_back(d);
            if (n/d!=d)divs.emplace_back(n/d);
        }
    }
    sort(divs.begin(), divs.end());
    c[1].insert(0);
    for (int g = 0; g < divs.size();g++){
        for (int j = 0; j < g; j++){
            if (divs[g]%divs[j]==0){
                for (auto x: c[divs[j]]) {
                    c[divs[g]].insert(x+divs[g]/divs[j]-1);
                }
            }
        }
    }

    cout<<c[divs.back()].size()<<endl;
    for (auto x: c[divs.back()]) 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...