Submission #1236617

#TimeUsernameProblemLanguageResultExecution timeMemory
1236617yassiaToys (CEOI18_toy)C++20
59 / 100
5094 ms93140 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, set<ll>&u1) { 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); set<ll> g; for (auto x1 : u1) { for (auto x2 : u1) { if (x1 == x2 && u.count(x1)<2){ continue; } new_.erase(new_.find(x1)); new_.erase(new_.find(x2)); new_.insert(x1*x2); g.clear(); for (auto y : new_)g.insert(y); if (e.find(new_)==e.end()) rec(new_, g); 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; 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 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...