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 LCMLCM. LCM(a,b)LCM(a, b) is the smallest positive integer xx which is divisible by both aa and bb.

Omkar, having a laudably curious mind, immediately thought of a problem involving the LCMLCM operation: given an integer nn, find positive integers aa and bb such that a+b=na + b = n and LCM(a,b)LCM(a, b) is the minimum value possible.

Can you help Omkar solve his ludicrously challenging math problem?

在奥姆卡尔(Omkar)最近的一节数学课上,他学习了最小公倍数(Least Common Multiple,简称 LCMLCM)。LCM(a,b)LCM(a, b) 是能同时被 aa 和 bb 整除的最小正整数 xx。

奥姆卡尔拥有值得称道的好奇心,立刻想到了一个与 LCMLCM 运算相关的问题:给定一个整数 nn,请找出正整数 aa 和 bb,使得 a+b=na + b = n,且 LCM(a,b)LCM(a, b) 尽可能小。

你能帮奥姆卡尔解决这个荒谬地具有挑战性的数学问题吗?

输入格式

Each test contains multiple test cases. The first line contains the number of test cases tt (1≤t≤101 \leq t \leq 10). Description of the test cases follows.

Each test case consists of a single integer nn (2≤n≤1092 \leq n \leq 10^{9}).

每个测试包含多个测试用例。第一行包含测试用例的数量 tt(1≤t≤101 \leq t \leq 10)。随后是测试用例的描述。

每个测试用例由一个整数 nn 组成(2≤n≤1092 \leq n \leq 10^{9})。

输出格式

For each test case, output two positive integers aa and bb, such that a+b=na + b = n and LCM(a,b)LCM(a, b) is the minimum possible.

对于每个测试用例,输出两个正整数 aa 和 bb,使得 a+b=na + b = n,且 LCM(a,b)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,31, 3 or 2,22, 2. LCM(1,3)=3LCM(1, 3) = 3 and LCM(2,2)=2LCM(2, 2) = 2, so we output 2 22 \ 2.

For the second test case, the numbers we can choose are 1,51, 5, 2,42, 4, or 3,33, 3. LCM(1,5)=5LCM(1, 5) = 5, LCM(2,4)=4LCM(2, 4) = 4, and LCM(3,3)=3LCM(3, 3) = 3, so we output 3 33 \ 3.

For the third test case, LCM(3,6)=6LCM(3, 6) = 6. It can be shown that there are no other pairs of numbers which sum to 99 that have a lower LCMLCM.

对于第一个测试用例,我们可以选择的数字对为 1,31, 3 或 2,22, 2。由于 LCM(1,3)=3\mathrm{LCM}(1, 3) = 3 且 LCM(2,2)=2\mathrm{LCM}(2, 2) = 2,因此我们输出 2 22 \ 2。

对于第二个测试用例,我们可以选择的数字对为 1,51, 5、2,42, 4 或 3,33, 3。由于 LCM(1,5)=5\mathrm{LCM}(1, 5) = 5、LCM(2,4)=4\mathrm{LCM}(2, 4) = 4 且 LCM(3,3)=3\mathrm{LCM}(3, 3) = 3,因此我们输出 3 33 \ 3。

对于第三个测试用例,LCM(3,6)=6\mathrm{LCM}(3, 6) = 6。可以证明:不存在其他和为 99 的数对,其最小公倍数更小。

输入解题思路,AI测评打分。不知道怎么写?

首页