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
  1. 4
    1 3 3 7
Output
  1. YES
    1 1
    1 3
    3 1
    1 7
Input
  1. 5
    3 1 3 3 7
Output
  1. NO
Input
  1. 6
    9 10 9 10 9 10
Output
  1. 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

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

  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int n;
  5.  
  6. struct E
  7. {
  8. int val;
  9. int index;
  10. } e[];
  11.  
  12. bool cmp(E a,E b)
  13. {
  14. return a.val < b.val;
  15. }
  16.  
  17. int ll[];
  18. int rr[];
  19. int main()
  20. {
  21. scanf("%d",&n);
  22. for(int i=; i<=n; i++)
  23. {
  24. scanf("%d",&e[i].val);
  25. e[i].index = i;
  26. }
  27. sort(e+,e++n,cmp);
  28. int cnt = ;
  29. int flag = ;
  30. for(int i=; i<=n; i++)
  31. {
  32. int l=i,r=i;
  33. while(r+<=n && e[r].val == e[r+].val)
  34. r++;
  35. for(int j=; j*j<=e[i].val; j++)
  36. {
  37. if(e[i].val % j == )
  38. {
  39. ll[e[l].index] = j;
  40. rr[e[l].index] = e[i].val / j;
  41. l++;
  42. if(l > r)break;
  43. if(j * j != e[i].val)
  44. {
  45. ll[e[l].index] = e[i].val / j;
  46. rr[e[l].index] = j;
  47. l++;
  48. if(l > r)break;
  49. }
  50. }
  51. }
  52. if(l <= r)
  53. {
  54. flag = ;
  55. break;
  56. }
  57. i = r;
  58. }
  59. if(flag)printf("NO\n");
  60. else
  61. {
  62. printf("YES\n");
  63. for(int i=;i<=n;i++)
  64. {
  65. printf("%d %d\n",ll[i],rr[i]);
  66. }
  67. }
  68. }

Masquerade strikes back Gym - 101911D (数学)的更多相关文章

  1. Masquerade strikes back Gym - 101911D(补题) 数学

    https://vjudge.net/problem/Gym-101911D 具体思路: 对于每一个数,假设当前的数是10 分解 4次,首先 1 10 这是一对,然后下一次就记录 10 1,这样的话直 ...

  2. gym 101911

    A. Coffee Break 题意:每天有m小时,你喝咖啡需要花一小时,你想在n个时刻都喝过一次咖啡,老板规定连续喝咖啡的间隔必须是d以上,求最少需要多少天才能喝够n次咖啡,并输出每个时刻第几天喝. ...

  3. 2018-2019 ACM-ICPC, NEERC, Southern Subregional Contest, Qualification Stage(11/12)

    2018-2019 ACM-ICPC, NEERC, Southern Subregional Contest, Qualification Stage A. Coffee Break 排序之后优先队 ...

  4. 【 Gym - 101124E 】Dance Party (数学)

    BUPT2017 wintertraining(15) #4G Gym - 101124 E.Dance Party 题意 有c种颜色,每个颜色最多分配给两个人,有M个男士,F个女士,求至少一对男士同 ...

  5. Codeforces Gym 100002 D"Decoding Task" 数学

    Problem D"Decoding Task" Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com ...

  6. Gym 101194E / UVALive 7901 - Ice Cream Tower - [数学+long double][2016 EC-Final Problem E]

    题目链接: http://codeforces.com/gym/101194/attachments https://icpcarchive.ecs.baylor.edu/index.php?opti ...

  7. 【Gym - 101124A】The Baguette Master (数学,几何)

    BUPT2017 wintertraining(15) #4F Gym - 101124A 题意 给定画框宽度,画的四边和一个对角线长度,求画框外沿周长. 题解 过顶点做画框的垂线,每个角都得到两个全 ...

  8. 【 Gym - 101138F 】GukiZ Height (数学)

    BUPT2017 wintertraining(15) #4 C Gym - 101138F 题意 初始高度0,目标值h,第i天目标值会下降i,当前高度会改变a[i%n],求高度不小于目标值的最早的时 ...

  9. 【推导】【数学期望】Gym - 101237D - Short Enough Task

    按照回文子串的奇偶分类讨论,分别计算其对答案的贡献,然后奇偶分别进行求和. 推导出来,化简一下……发现奇数也好,偶数也好,都可以拆成一个等比数列求和,以及一个可以错位相减的数列求和. 然后用高中数学知 ...

随机推荐

  1. C#获取当前主机硬件信息

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...

  2. Notepad++怎么增加整行删除快捷键?添加/取消区块注释?

    1.有网友说 Notepad++ 自带删除行功能,用快捷键 Ctrl+L 就可以删除一行.的确,这个快捷键是可以删除一行文本,但确切的说,Ctrl+L 并不是仅仅删除了一行文本,而是 剪切 了一行文本 ...

  3. Confluence 6 推荐的更新通知设置和禁用

    你可以设置默认的发送选项(发送 / 不发送)和默认的发送时间(每天或每周). 如何配置推荐更新电子邮件通知: 在屏幕的右上角单击 控制台按钮 ,然后选择 General Configuration 链 ...

  4. 移动端的dl

    https://blog.csdn.net/u013139259/article/details/52143240

  5. spring-boot与spring-data-JPA的简单整合

    如何在boot中轻松使用JPA <!--首先引入JPA依赖--><dependency> <groupId>org.springframework.boot< ...

  6. [Gym-102091E] How Many Groups

    /* 先将a数组从小到大排序 dp[i][j][k]表示到以第i个数为结尾的,且第i个数改了j次,第i个数改动值为k-1的集合最大值 ans是dp过程中的最大集合大小 状态转移: 首先是到i改动为0次 ...

  7. bzoj 1002

    表示我这种蒟蒻面对这种递推第一思想显然是打表啊 先贴个用来打表的暴力: #include <cstdio> struct node {     int l,r; }p[]; ]; ]; i ...

  8. Jmeter测试demo

    复制代码,保存为.jmx文件 需要安装插件: JMeterPlugins-ExtrasLibs E:\软件\apache-jmeter-3.0\lib\ext <?xml version=&qu ...

  9. Centos7.4上Apache(http)编译安装

    前提:1.这个centos操作系统能上网 2.yum 安装apr,apr-util,zlib-devel,groupinstall  Development  Tools,gcc 1.在apache的 ...

  10. 步步为营-90-SEO(url重写+超链接技巧)

    目的:便于搜索引擎抓取 url重写:将带参数的url如:https://i.cnblogs.com/EditPosts.aspx?opt=1.修改为https://i.cnblogs.com/Edit ...