Codeforce - Runtime Error

Bahosain遇到一个运行时错误的问题,需要在给定的非负整数数组中找到两个不同索引的数X和Y,使得X×Y=K。如果不存在解决方案,则输出-1;若存在多个解,输出X最小的解。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Bahosain was trying to solve this simple problem, but he got a Runtime Error on one of the test cases, can you help him by solving it?

Given an array of N non-negative integers and an integer K, your task is to find two integers X and Y from the given array such that X × Y = K.

The chosen numbers must have different indices in the   array.

Input

The first line of input contains T (1 ≤ T ≤ 128), the number of test   cases.

The first line of each test case contains two integers: N (2 ≤ N ≤ 100,000) and K (1 ≤ K ≤ 100,000). The next line contains N space-separated integers, each between 0 and   100,000.

Output

For each test case, if there is no solution, print -1 on a single line. Otherwise print a single line with two space-separated integers X Y (X ≤   Y), where X and Y are two numbers from the given array and X × Y = K.

If there is more than one possible solution, print the one with the minimum   X.

Sample Input

Sample Output

4

 

 

2 6

6 12

 

</
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值