Submission #598219

#TimeUsernameProblemLanguageResultExecution timeMemory
598219MounirToys (CEOI18_toy)C++14
19 / 100
1 ms212 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<int> sommes; void calcul(vector<int> jouets, int somme){ sommes.insert(somme); /* 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; int sumTrans = jouets[i] * jouets[j]; for (int k = 0; k < sz(jouets); ++k){ if (k != i && k != j) trans.pb(jouets[k]), sumTrans += jouets[k]; } sumTrans -= sz(trans) + 1; if (sommes.count(sumTrans) == 0){ trans.pb(jouets[i] * jouets[j]); sort(all(trans)); calcul(trans, sumTrans); } } } } signed main(){ int produit; cin >> produit; int bSup = 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); int somme = 0; for (int premier : premiers) somme += premier; somme -= sz(premiers); calcul(premiers, somme); cout << sz(sommes) << endl; for (int sum : sommes) 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...