Submission #405823

#TimeUsernameProblemLanguageResultExecution timeMemory
405823abdzagToys (CEOI18_toy)C++17
59 / 100
5088 ms201032 KiB
#include<bits/stdc++.h> #include<unordered_map> #define rep(i,a,b) for(int i=int(a);i<int(b);i++) #define rrep(i,a,b) for(int i=int(a);i>int(b);i--) #define all(v) v.begin(),v.end() #define trav(a,v) for(auto&a:v) #define sz(a) a.size() typedef long double ld; using namespace std; const long long inf = 1e15; typedef long long ll; typedef unsigned long long ull; vector<multiset<ll>> res; int main() { cin.sync_with_stdio(false); vector<ll> primes; map<ll, bool> is_prime; primes.push_back(2); rep(i, 3, 1e6) { ll val = sqrt(i); val++; ll ind = upper_bound(all(primes), val) - primes.begin(); bool done = true; rep(j, 0, ind) { if (i % primes[j] == 0) { done = false; break; } } if (done) { is_prime[i] = 1; primes.push_back(i); } } ll n; cin >> n; ll cur = n; vector<ll> v; rep(i, 0, primes.size()) { if (cur % primes[i] == 0) { v.push_back(primes[i]); cur /= primes[i]; i--; } } if (cur != 1)v.push_back(cur); vector<ll> pr; map<multiset<ll>, bool> visited; queue<pair<multiset<ll>, multiset<ll>>> q; multiset<ll>node; multiset<ll> v2; trav(a, v)v2.insert(a); q.emplace(v2, node); while (!q.empty()) { pair<multiset<ll>, multiset<ll>> cur = q.front(); q.pop(); ll counter = 0; if (cur.first.size() == 0)res.push_back(cur.second); trav(a, cur.first) { multiset<ll> ny = cur.first; multiset<ll> ny2; vector<ll> ny20; trav(a, cur.second)ny20.push_back(a); ny.erase(ny.find(a)); rep(j, 0, cur.second.size()) { ny2.clear(); rep(z, 0, cur.second.size()) { if (z == j) { ny2.insert(a * ny20[z]); } else ny2.insert(ny20[z]); } if (!visited[ny2]) { visited[ny2] = 1; q.emplace(make_pair(ny, ny2)); } } ny2 = cur.second; ny2.insert(a); if (!visited[ny2]) { visited[ny2] = 1; q.emplace(make_pair(ny, ny2)); } } } set<ll> ans; rep(i, 0, res.size()) { ll val = 0; trav(a, res[i]) { val += a - 1; } ans.insert(val); } cout << ans.size() << endl; trav(a, ans)cout << a << " "; return 0; }

Compilation message (stderr)

toy.cpp: In function 'int main()':
toy.cpp:57:6: warning: unused variable 'counter' [-Wunused-variable]
   57 |   ll counter = 0;
      |      ^~~~~~~
#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...