CF1372B.Omkar and Last Class of Math
普及-
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
In Omkar's last class of math, he learned about the least common multiple, or LCM. LCM(a,b) is the smallest positive integer x which is divisible by both a and b.
Omkar, having a laudably curious mind, immediately thought of a problem involving the LCM operation: given an integer n, find positive integers a and b such that a+b=n and LCM(a,b) is the minimum value possible.
Can you help Omkar solve his ludicrously challenging math problem?
在奥姆卡尔(Omkar)最近的一节数学课上,他学习了最小公倍数(Least Common Multiple,简称 LCM)。LCM(a,b) 是能同时被 a 和 b 整除的最小正整数 x。
奥姆卡尔拥有值得称道的好奇心,立刻想到了一个与 LCM 运算相关的问题:给定一个整数 n,请找出正整数 a 和 b,使得 a+b=n,且 LCM(a,b) 尽可能小。
你能帮奥姆卡尔解决这个荒谬地具有挑战性的数学问题吗?
输入格式
Each test contains multiple test cases. The first line contains the number of test cases t (1≤t≤10). Description of the test cases follows.
Each test case consists of a single integer n (2≤n≤109).
每个测试包含多个测试用例。第一行包含测试用例的数量 t(1≤t≤10)。随后是测试用例的描述。
每个测试用例由一个整数 n 组成(2≤n≤109)。
输出格式
For each test case, output two positive integers a and b, such that a+b=n and LCM(a,b) is the minimum possible.
对于每个测试用例,输出两个正整数 a 和 b,使得 a+b=n,且 LCM(a,b) 尽可能小。
输入输出样例
输入#1
3 4 6 9
输出#1
2 2 3 3 3 6
说明/提示
For the first test case, the numbers we can choose are 1,3 or 2,2. LCM(1,3)=3 and LCM(2,2)=2, so we output 2 2.
For the second test case, the numbers we can choose are 1,5, 2,4, or 3,3. LCM(1,5)=5, LCM(2,4)=4, and LCM(3,3)=3, so we output 3 3.
For the third test case, LCM(3,6)=6. It can be shown that there are no other pairs of numbers which sum to 9 that have a lower LCM.
对于第一个测试用例,我们可以选择的数字对为 1,3 或 2,2。由于 LCM(1,3)=3 且 LCM(2,2)=2,因此我们输出 2 2。
对于第二个测试用例,我们可以选择的数字对为 1,5、2,4 或 3,3。由于 LCM(1,5)=5、LCM(2,4)=4 且 LCM(3,3)=3,因此我们输出 3 3。
对于第三个测试用例,LCM(3,6)=6。可以证明:不存在其他和为 9 的数对,其最小公倍数更小。
输入解题思路,AI测评打分。不知道怎么写?