CF1370A.Maximum GCD
入门
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Let's consider all integers in the range from 1 to n (inclusive).
Among all pairs of distinct integers in this range, find the maximum possible greatest common divisor of integers in pair. Formally, find the maximum value of gcd(a,b), where 1≤a<b≤n.
The greatest common divisor, gcd(a,b), of two positive integers a and b is the biggest integer that is a divisor of both a and b.
考虑所有在 1 到 n(含端点)范围内的整数。
在该范围内所有互不相同的整数对中,找出整数对中两数的最大可能最大公约数。形式化地说,即求 gcd(a,b) 的最大值,其中 1≤a<b≤n。
两个正整数 a 和 b 的最大公约数 gcd(a,b) 是同时整除 a 和 b 的最大整数。
输入格式
The first line contains a single integer t (1≤t≤100) — the number of test cases. The description of the test cases follows.
The only line of each test case contains a single integer n (2≤n≤106).
第一行包含一个整数 t(1≤t≤100)—— 表示测试用例的数量。随后是各测试用例的描述。
每个测试用例仅有一行,包含一个整数 n(2≤n≤106)。
输出格式
For each test case, output the maximum value of gcd(a,b) among all 1≤a<b≤n.
对于每个测试用例,输出所有满足 1≤a<b≤n 的整数对 (a,b) 中 gcd(a,b) 的最大值。
输入输出样例
输入#1
2 3 5
输出#1
1 2
说明/提示
In the first test case, gcd(1,2)=gcd(2,3)=gcd(1,3)=1.
In the second test case, 2 is the maximum possible value, corresponding to gcd(2,4).
在第一个测试用例中,gcd(1,2)=gcd(2,3)=gcd(1,3)=1。
在第二个测试用例中,最大可能值为 2,对应于 gcd(2,4)。
输入解题思路,AI测评打分。不知道怎么写?