This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |