Recently you have received two positive integer numbers xx and yy. You forgot them, but you remembered a shuffled list containing all divisors of xx (including 11 and xx) and all divisors of yy (including 11 and yy). If dd is a divisor of both numbers xx and yy at the same time, there are two occurrences of dd in the list.

For example, if x=4x=4 and y=6y=6 then the given list can be any permutation of the list [1,2,4,1,2,3,6][1,2,4,1,2,3,6]. Some of the possible lists are: [1,1,2,4,6,3,2][1,1,2,4,6,3,2], [4,6,1,1,2,3,2][4,6,1,1,2,3,2]or [1,6,3,2,4,1,2][1,6,3,2,4,1,2].

Your problem is to restore suitable positive integer numbers xx and yy that would yield the same list of divisors (possibly in different order).

It is guaranteed that the answer exists, i.e. the given list of divisors corresponds to some positive integers xx and yy.

Input

The first line contains one integer nn (2≤n≤1282≤n≤128) — the number of divisors of xxand yy.

The second line of the input contains nn integers d1,d2,…,dnd1,d2,…,dn (1≤di≤1041≤di≤104), where didi is either divisor of xx or divisor of yy. If a number is divisor of both numbers xxand yy then there are two copies of this number in the list.

Output

Print two positive integer numbers xx and yy — such numbers that merged list of their divisors is the permutation of the given list of integers. It is guaranteed that the answer exists.

Example

Input
10
10 2 8 1 2 4 1 20 4 5
Output
20 8

题意:
给定一个数组,这个数组包含了两个正整数a和b的所有因子,包括1和a,b,如果x同为a和b的因子,那么数组中x出现两次。
让求出a和b的数值。
思路:首先对数组进行排序,那么最大值一定是我们a和b中的一个(原因自行思考)。那么我们最大值是a。
然后我们暴力的把a的所有因子都求出来,从数组中删除一次,然后剩下的数组中的最大值就是我们要找的b。
细节见代码:
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#define sz(a) int(a.size())
#define all(a) a.begin(), a.end()
#define rep(i,x,n) for(int i=x;i<n;i++)
#define repd(i,x,n) for(int i=x;i<=n;i++)
#define pii pair<int,int>
#define pll pair<long long ,long long>
#define gbtb ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MSC0(X) memset((X), '\0', sizeof((X)))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define eps 1e-6
#define gg(x) getInt(&x)
#define db(x) cout<<"== [ "<<x<<" ] =="<<endl;
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll powmod(ll a,ll b,ll MOD){ll ans=;while(b){if(b%)ans=ans*a%MOD;a=a*a%MOD;b/=;}return ans;}
inline void getInt(int* p);
const int maxn=;
const int inf=0x3f3f3f3f;
/*** TEMPLATE CODE * * STARTS HERE ***/
ll n;
ll a[maxn];
int main()
{
gbtb;
cin>>n;
map<ll,ll> m;
repd(i,,n)
{
cin>>a[i];
m[a[i]]++;
}
sort(a+,a++n); ll x=1ll;
ll y=1ll;
y=a[n]; for(ll i=;i<=y;i++)
{
if(y%i==)
m[i]--;
}
for(ll i=;i>=;i--)
{
if(m[i]==)
{
x=i;
break;
}
}
cout<<x<<" "<<y;
return ;
} inline void getInt(int* p) {
char ch;
do {
ch = getchar();
} while (ch == ' ' || ch == '\n');
if (ch == '-') {
*p = -(getchar() - '');
while ((ch = getchar()) >= '' && ch <= '') {
*p = *p * - ch + '';
}
}
else {
*p = ch - '';
while ((ch = getchar()) >= '' && ch <= '') {
*p = *p * + ch - '';
}
}
}

最新文章

  1. JS中循环绑定遇到的问题及解决方法
  2. Asp.net 未处理异常
  3. 嵌入式Linux内核制作【转】
  4. 用easyui动态创建一个对话框
  5. uvalive 7331 Hovering Hornet 半平面交+概率期望
  6. PHP用memcached做实时分页
  7. onbeforeunload、beforeunload
  8. 2015第37周五javascript函数arguments对象巧用一
  9. WebBrowser脚本错误的完美解决方案
  10. validform.js使用方法
  11. ArcGIS 10.1 for Server 扩展开发(SOE)
  12. C#使用SqlDataAdapter 实现数据的批量插入和更新
  13. SQLServer 创建服务器和数据库级别审计
  14. 通过 mysqlbinlog 和 grep 命令定位binlog文件中指定操作
  15. 持续集成①安装部署jenkins从git获取代码
  16. Nginx教程--02.Nginx虚拟主机的配置
  17. 一本通1548【例 2】A Simple Problem with Integers
  18. openshift 容器云从入门到崩溃之三《安装openshift》
  19. python string method
  20. win10更改hosts文件

热门文章

  1. shell编程 学好内功(一)
  2. 通过Socket实现TCP编程,用户登录之服务器相应客户端,客户端和服务端之间的通信
  3. [Hive_6] Hive 的内置函数应用
  4. LeetCode算法题-Convert a Number to Hexadecimal(Java实现)
  5. python 进程介绍 进程简单使用 join 验证空间隔离
  6. C#のsocket通信
  7. postgresql + mybatis insert主键自增方法
  8. Linux系统下为何病毒少?原因竟是这个?
  9. PHP程序员遇到职业问题时,是离职?还是坚持?
  10. centos7下安装docker(18.2docker日志---ELK)