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 gtypist

    一.简介 Typist (gtypist)是一个打字练习软件,用来提升打字的速度.   二.安装 1)源码方式 http://ftp.gnu.org/gnu/gtypist/   三.使用 http: ...

  2. py_initialize:C调Python出错 是初始化错误?

    还是pythonpath和pythonname变量没有配置正确? py_initialize()方法是什么? In an application embedding Python, this shou ...

  3. HackTen 格式化TextView的文本

    1.概要:     TextView是Android提供的一个简单却功能强大的UI控件.读者可以在应用程序中通过多种方法使用不同样式的文本. 监管TextView并不支持所有HTML标签,但是用于格式 ...

  4. Sharepoint2013搜索学习笔记之搜索构架简单概述(一)

    Sharepoint搜索引擎主要由6种组件构成,他们分别是爬网组件,内容处理组件,分析处理组件,索引组件,查询处理组件,搜索管理组件.可以将这6种组件分别部署到Sharepoint场内的多个服务器上, ...

  5. Job-Show Liang,你来掌管诺基亚王国,可好?

    保留我一向高大上风格,开头当然来一个段子 在即将到来MWC(Mobile World Congress缩写,世界移动通信大会),很高兴能听到小诺来参展,我不得不给它32个赞,因为小诺已经好几届没有浮头 ...

  6. angular 第二种依赖注入

    import { Injectable } from '@angular/core'; import { ProductServiceService, Product } from './produc ...

  7. jquery.validate弹窗验证

     $(document).ready(function () { //开始验证        $("#form1").validate({            submitHan ...

  8. C# LINQ(7)

    大部分的LINQ的关键字都说了,最后说一下排序吧. LINQ的是查询的利器. 那么查询就会有排序. 所有LINQ提供了两种简单的排序.倒序和默认排序. 关键字是: orderby ascending ...

  9. Spark大数据处理 之 从WordCount看Spark大数据处理的核心机制(1)

    大数据处理肯定是分布式的了,那就面临着几个核心问题:可扩展性,负载均衡,容错处理.Spark是如何处理这些问题的呢?接着上一篇的"动手写WordCount",今天要做的就是透过这个 ...

  10. [ADB Shell]Android Debug Bridge常用命令

    ADB用法 *:first-child { margin-top: 0 !important; } body>*:last-child { margin-bottom: 0 !important ...