time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

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 xx and 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 xx and 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

Copy
10
10 2 8 1 2 4 1 20 4 5
output

Copy
20 8
#include<iostream>
#include<algorithm>
using namespace std;
#define ll long long
int a[],b[];
int main()
{
int n,j=;
cin>>n;
for(int i=;i<n;i++)
{
cin>>a[i];
}
sort(a,a+n);
cout<<a[n-]<<" ";
for(int i=;i<=a[n-];i++)
{
if(a[n-]%i==)
{
b[j]=i;
j++;
}
}
for(int k=;k<j;k++)
{
for(int i=;i<n;i++)
{
if(a[i]==b[k])
{
a[i]=;
break;
}
}
}
sort(a,a+n);
cout<<a[n-]<<endl; return ; }

B. Divisors of Two Integers的更多相关文章

  1. Divisors of Two Integers CodeForces - 1108B (数学+思维)

    Recently you have received two positive integer numbers xx and yy. You forgot them, but you remember ...

  2. codeforce --- 237C

    C. Primes on Interval time limit per test 2 seconds memory limit per test 256 megabytes input standa ...

  3. Primes on Interval(二分 + 素数打表)

    Primes on Interval Time Limit:1000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u ...

  4. Codeforces 237C

    题目: Description You've decided to carry out a survey in the theory of prime numbers. Let us remind y ...

  5. Codeforces Round #535 (Div. 3) 解题报告

    CF1108A. Two distinct points 做法:模拟 如果两者左端点重合就第二条的左端点++就好,然后输出左端点 #include <bits/stdc++.h> usin ...

  6. Codeforces Round #535 (Div. 3) 题解

    Codeforces Round #535 (Div. 3) 题目总链接:https://codeforces.com/contest/1108 太懒了啊~好久之前的我现在才更新,赶紧补上吧,不能漏掉 ...

  7. Codeforces Round #535 (Div. 3) [codeforces div3 难度测评]

    hhhh感觉我真的太久没有接触过OI了 大约是前天听到JK他们约着一起刷codeforces,假期里觉得有些颓废的我忽然也心血来潮来看看题目 今天看codeforces才知道居然有div3了,感觉应该 ...

  8. Codeforces Round #535(div 3) 简要题解

    Problem A. Two distinct points [题解] 显然 , 当l1不等于r2时 , (l1 , r2)是一组解 否则 , (l1 , l2)是一组合法的解 时间复杂度 : O(1 ...

  9. 【Codeforces1139D_CF1139D】Steps to One (Mobius_DP)

    Problem: Codeforces 1139D Analysis: After ACing E, I gave up D and spent the left 30 minutes chattin ...

随机推荐

  1. linux下安装sz/rz命令

    参考 https://blog.csdn.net/kobejayandy/article/details/13291655

  2. Why does my Authorize Attribute not work?

    the roles of a ClaimsPrincipal are actually just claims create with a type of ClaimsIdentity.RoleCla ...

  3. myeclipse自动化提示

    jsp自动提示:1.快捷键提示代码 window-->Preferences的General-->Keys下修改Content Assist的快捷键为Alt+/,这样就可以通过快捷键得到提 ...

  4. c++基础之向量Vector

    首先和string一样要在开头 #include <vector> #include <string> 和string一样,也算是一种容器,而且同属于STL(standard ...

  5. 关于Java异常一段很有意思的代码

    今天学习了Java的异常,讲到try-catch-finally时,老师演示了一段代码,觉得很有意思,很能反映出其执行的过程,让自己有点绕,特意记录一下. 只要代码执行到try代码内部, 不管有没有异 ...

  6. 桥梁(Bridge)模式

    桥梁(Bridge)模式:桥梁模式是一个非常有用的模式,也是比较复杂的一个模式.熟悉这个模式对于理解面向对象的设计原则,包括"开-闭"原则(OCP)以及组合/聚合复用原则(CARP ...

  7. 使用VS Code编写Markdown文件

    VS Code默认支持Markdown文件文件格式,这里介绍两个比较实用的功能,后续有新发现,可以持续更新. 实时预览 顾名思义,实时编辑,实时预览解析效果. 在VS Code扩展中搜索"M ...

  8. rsync实时备份备份服务搭建和使用指南

    一.Rsync企业工作场景说明: 1.利用定时任务+rsync方式实现数据同步 对于网站内部技术人员创建的数据,可以采取定时任务的方式 2.利用实时任务+rsync方式实现数据同步 对于网站外部访问用 ...

  9. kubernetes api文档

    http://kubernetes.kansea.com/docs/api-reference/v1/definitions/

  10. linking against a dylib which is not safe for use in application extensions

    完成到这里可能会出现警告 linking against a dylib which is not safe for use in application extensions 解决办法: