Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define int int64_t
- const int inf = 2e18;
- const int mod = 1e9 + 7;
- const int max_x = 200000 + 1;
- int32_t main() {
- ios_base::sync_with_stdio(0);
- cin.tie(0); cout.tie(0);
- int n;
- cin >> n;
- vector<vector<int>> powers(max_x);
- for (int i = 0; i < n; i++) {
- int a;
- cin >> a;
- int a_copy = a;
- for (int i = 2; i * i <= a_copy; i++) {
- int p = 0;
- while (a_copy % i == 0) {
- a_copy /= i;
- p++;
- }
- if (p > 0) {
- powers[i].push_back(p);
- }
- }
- if (a_copy > 1) {
- powers[a_copy].push_back(1);
- }
- }
- int res = 1;
- for (int i = 2; i < max_x; i++) {
- if (powers[i].size() <= n - 2) {
- continue;
- }
- if (powers[i].size() == n - 1) {
- powers[i].push_back(0);
- }
- sort(powers[i].begin(), powers[i].end());
- int p = powers[i][1];
- for (int j = 0; j < p; j++) {
- res *= i;
- }
- }
- cout << res << '\n';
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement