CF1372B.Omkar and Last Class of Math

传统题 时间 1000 ms 内存 256 MiB 10 尝试 5 已通过 4 标签

Omkar and Last Class of Math

CF1372B · Omkar and Last Class of Math

  • 难度:1300
  • 标签:greedy、math、number theory
  • 链接:https://codeforces.com/problemset/problem/1372/B
  • 时间限制:1 second 内存限制:256 megabytes
  • 出现位置:假期自习包/A-数学基础(快速幂/筛法/gcd/组合数取模)

英文原题面

Statement

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?

Input

Each test contains multiple test cases. The first line contains the number of test cases tt (1t101 \leq t \leq 10). Description of the test cases follows. Each test case consists of a single integer nn (2n1092 \leq n \leq 10^{9}).

Output

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.

样例

样例 1

输入:

3
4
6
9

输出:

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.

在线编程 IDE

建议全屏模式获得最佳体验