首页 技术 正文
技术 2022年11月18日
0 收藏 927 点赞 3,125 浏览 2304 个字

Quite often the jury of Saratov SU use the problem “Masquerade” in different practice sessions before the contest. This problem is quite easy — all you need is to print the product of two integers which were read from the input stream.

As usual, the jury had prepared this problem once again. The jury had nn testcases, the ii -th testcase was a pair of positive integers aiai and bibi , both integers didn’t exceed 107107 . All testcases were pairwise distinct.

Unfortunately, something went wrong. Due to hardware issues all testcases have disappeared. All that the jury were able to restore are the number of testcases nn and the answers to these testcases, i. e. a sequence of nn numbers c1,c2,…,cnc1,c2,…,cn , such that ai⋅bi=ciai⋅bi=ci .

The jury ask you to help them. Can you provide any possible testset? Remember that all testcases were distinct and all numbers in each testcase were positive integers and didn’t exceed 107107 .

Input

First line contains one insteger nn (1≤n≤2⋅1051≤n≤2⋅105 ) — the number of lost testcases.

Second line contains nn space-separated integers c1,c2,…,cnc1,c2,…,cn (1≤ci≤1071≤ci≤107 ) — the answers to the testcases.

Output

If there is no such testset, print NO.

Otherwise, print YES in first line. Then print nn more lines, the ii -th of them should contain two space separated positive integers aiai and bibi not exceeding 107107 . All pairs (ai,bi)(ai,bi) must be distinct, and, for each i∈[1,n]i∈[1,n] , the condition ai⋅bi=ciai⋅bi=ci must be met.

Examples

Input

4
1 3 3 7

Output

YES
1 1
1 3
3 1
1 7

Input

5
3 1 3 3 7

Output

NO

Input

6
9 10 9 10 9 10

Output

YES
1 9
1 10
3 3
5 2
9 1
2 5

Note

In the first example one of the possible testsets is (a1=1a1=1 , b1=1b1=1 ), (a2=1a2=1 , b2=3b2=3 ), (a3=3a3=3 , b3=1b3=1 ), (a4=1a4=1 , b4=7b4=7 ).

In the second example a testset consisting of distinct tests doesn’t exist.

题意:给出n个数,让你将每个数都表示成两个数相乘,但是不能重复,(1*3和3*1不算重复)可以就输出结果,否则输出NO

思路:对于给出的数里,相同的数我们可以一起处理,即可以先排序,然相同的数挨在一起,我们可以统计其个数,然后在这个数开方范围内寻找因子。最后统计该数出现的个数和式子数时候满足要求,即式子是否足够多。

#include<bits/stdc++.h>
using namespace std;int n;struct E
{
int val;
int index;
} e[];bool cmp(E a,E b)
{
return a.val < b.val;
}int ll[];
int rr[];
int main()
{
scanf("%d",&n);
for(int i=; i<=n; i++)
{
scanf("%d",&e[i].val);
e[i].index = i;
}
sort(e+,e++n,cmp);
int cnt = ;
int flag = ;
for(int i=; i<=n; i++)
{
int l=i,r=i;
while(r+<=n && e[r].val == e[r+].val)
r++;
for(int j=; j*j<=e[i].val; j++)
{
if(e[i].val % j == )
{
ll[e[l].index] = j;
rr[e[l].index] = e[i].val / j;
l++;
if(l > r)break;
if(j * j != e[i].val)
{
ll[e[l].index] = e[i].val / j;
rr[e[l].index] = j;
l++;
if(l > r)break;
}
}
}
if(l <= r)
{
flag = ;
break;
}
i = r;
}
if(flag)printf("NO\n");
else
{
printf("YES\n");
for(int i=;i<=n;i++)
{
printf("%d %d\n",ll[i],rr[i]);
}
}
}
相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,104
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,581
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,428
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,200
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,835
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,918