Submission #598225

#TimeUsernameProblemLanguageResultExecution timeMemory
598225MounirToys (CEOI18_toy)C++14
59 / 100
5091 ms59156 KiB
#include <bits/stdc++.h> #define all(v) v.begin(), v.end() #define sz(x) (int)x.size() #define pb push_back #define pii pair<int, int> #define chmin(x, v) x = min(x, v) #define chmax(x, v) x = max(x, v) #define print(x) cout << #x << " est " << x << endl; #define x first #define y second //#define int long long using namespace std; set<vector<int>> sommes; void calcul(vector<int> jouets){ sommes.insert(jouets); /* cout << "JOUET " << somme << endl; for (int jouet : jouets) cout << jouet << " "; cout << endl;*/ for (int i = 0; i < sz(jouets); ++i){ for (int j = i + 1; j < sz(jouets); ++j){ vector<int> trans; for (int k = 0; k < sz(jouets); ++k){ if (k != i && k != j) trans.pb(jouets[k]); } // sumTrans -= sz(trans) + 1; trans.pb(jouets[i] * jouets[j]); sort(all(trans)); if (sommes.count(trans) == 0) calcul(trans); } } } signed main(){ ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); int produit; cin >> produit; int bSup = sqrt(produit); vector<int> premiers; int test = 2; while (produit != 1 && test <= bSup){ if (produit%test == 0) premiers.pb(test), produit /= test; else test++; } if (produit != 1) premiers.pb(produit); calcul(premiers); set<int> toprint; for (vector<int> jouets : sommes){ int sum = -sz(jouets); for (int jouet : jouets) sum += jouet; toprint.insert(sum); } cout << sz(toprint) << endl; for (int sum : toprint) cout << sum << " "; cout << endl; return 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...