AT_abc475_g.Has Many Divisors
省选/NOI-
通过率:0%
时间限制:2.00s
内存限制:1024MB
AC君温馨提醒
该题目为【atcoder】题库的题目,您提交的代码将被提交至atcoder进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are given integers N and D, each at least 2.
Among the positive integers at most N that are not multiples of D, find one with the maximum number of positive divisors. If there are multiple such positive integers, output any one of them.
You are given T test cases; solve each of them.
给你两个整数 N 和 D,均至少为 2。
在不超过 N 的正整数中,找出一个不是 D 的倍数的数,使其正因数个数最多。若存在多个满足条件的数,输出其中任意一个即可。
你将得到 T 组测试数据;请对每组数据分别求解。
输入格式
The input is given from Standard Input in the following format:
T
case1
case2
⋮
caseT
Here, casei represents the i-th test case, and is given in the following format:
N D
输入从标准输入中按以下格式给出:
T
case1
case2
⋮
caseT
其中,casei 表示第 i 个测试用例,其格式如下:
N D
输出格式
Output T lines. The i-th line should contain the answer for the i-th test case.
输出 T 行。第 i 行应包含第 i 个测试用例的答案。
输入输出样例
输入#1
4 10 2 17 4 2026 919 1000000000000 48
输出#1
9 15 1680 843291048600
说明/提示
Sample 1 Explanation:
The positive integers at most 10 that are not multiples of 2 are the five integers 1,3,5,7,9, and the numbers of their positive divisors are 1,2,2,2,3, respectively. Therefore, output 9 for the first test case.
For the second test case, besides 15 in the sample output, outputting any of 6,10,14 is also accepted.
Constraints
- 1≤T≤10
- 2≤D≤N≤1018
- All input values are integers.
样例 1 解释:
不超过 10 的正整数中,不是 2 的倍数的数共有五个:1,3,5,7,9;它们各自的正因数个数分别为 1,2,2,2,3。因此,第一个测试用例的输出为 9。
对于第二个测试用例,除样例输出中的 15 外,输出 6,10,14 中的任意一个也被接受。
约束条件
- 1≤T≤10
- 2≤D≤N≤1018
- 所有输入值均为整数。
输入解题思路,AI测评打分。不知道怎么写?