Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #define MAX 1000002
- using namespace std;
- long v[MAX];
- int main() {
- ios_base::sync_with_stdio(0);
- cin.tie(0);
- cout.tie(0);
- long n;
- cin >> n;
- for(int i = 0; i < n; ++i) {
- long test;
- cin >> test;
- v[test]++;
- }
- for(int i = MAX; i >= 1; --i) {
- long a = 0, b = 0;
- for(int j = MAX-(MAX%i); j > 0; j -= i) {
- if(v[j] && !a) {
- if(v[j] > 1) {
- a = j;
- b = j;
- break;
- }
- else a = j;
- }
- else if(v[j] && a && !b) {
- b = j;
- break;
- }
- }
- if(a && b) {
- (a%b == 0) ? cout << a : cout << ((a*b)/i);
- return 0;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement