CF1549A.Gregor and Cryptography
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Gregor is learning about RSA cryptography, and although he doesn't understand how RSA works, he is now fascinated with prime numbers and factoring them.
Gregor's favorite prime number is P . Gregor wants to find two bases of P . Formally, Gregor is looking for two integers a and b which satisfy both of the following properties.
- Pmoda=Pmodb , where xmody denotes the remainder when x is divided by y , and
- 2≤a<b≤P .
Help Gregor find two bases of his favorite prime number!
输入格式
Each test contains multiple test cases. The first line contains the number of test cases t ( 1≤t≤1000 ).
Each subsequent line contains the integer P ( 5≤P≤109 ), with P guaranteed to be prime.
输出格式
Your output should consist of t lines. Each line should consist of two integers a and b ( 2≤a<b≤P ). If there are multiple possible solutions, print any.
输入输出样例
输入#1
2 17 5
输出#1
3 5 2 4
说明/提示
The first query is P=17 . a=3 and b=5 are valid bases in this case, because 17mod3=17mod5=2 . There are other pairs which work as well.
In the second query, with P=5 , the only solution is a=2 and b=4 .