Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <algorithm>
- #include <vector>
- #include <cmath>
- using namespace std;
- int main() {
- int n;
- cin >> n;
- int niza[n];
- for(int i = 0; i < n; i++) {
- cin >> niza[i];
- }
- sort(niza, niza + n);
- int najmal_broj_na_deliteli = 2000000000;
- vector<pair<int, int> > v;
- do {
- int number = 0;
- for(int i = 0; i < n; i++) {
- number = (number * 10) + niza[i];
- }
- int deliteli = 0;
- for(int i = 1; i <= sqrt(number); i++) {
- if(number % i == 0) {
- deliteli++;
- if(i != number / i) {
- deliteli++;
- }
- }
- }
- if(deliteli < najmal_broj_na_deliteli) {
- najmal_broj_na_deliteli = deliteli;
- }
- v.push_back(make_pair(number, deliteli));
- } while(next_permutation(niza, niza + n));
- cout << najmal_broj_na_deliteli << endl;
- for(int i = 0; i < v.size(); i++) {
- if(v[i].second == najmal_broj_na_deliteli) {
- cout << v[i].first << " ";
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement