Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <set>
- #include <cmath>
- #include <algorithm>
- using namespace std;
- bool prime(int n) {
- for (int i = 2; i < sqrt(n) + 1; i++) {
- if (n % i == 0) { return false; }
- }
- return true;
- }
- int div(int n) {
- int count = 0;
- for (int i = 2; i <= n; i++) {
- if (n % i == 0 && prime(i)) { count++; }
- }
- return count;
- }
- int min(int a, int b) {
- if (a < b) { return a; }
- else { return b; }
- }
- int main() {
- int n, ans = 0;
- cin >> n;
- vector<int> vec;
- sort(vec.begin(), vec.end());
- for (int i = 0; i < n; i++) {
- int k;
- cin >> k;
- vec.push_back(k);
- }
- int c = 0, c1 = 0;
- for (int i = 0; i < n; i++) {
- c = div(vec[i]);
- if (c1 < c) {
- ans = vec[i];
- c1 = c;
- }
- else if (c1 == c) {
- ans = min(ans, vec[i]);
- }
- }
- cout << ans;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement