AT_abc475_g.Has Many Divisors

省选/NOI-

通过率:0%

时间限制:2.00s

内存限制:1024MB

AC君温馨提醒

该题目为【atcoder】题库的题目,您提交的代码将被提交至atcoder进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

You are given integers NN and DD, each at least 22.

Among the positive integers at most NN that are not multiples of DD, find one with the maximum number of positive divisors. If there are multiple such positive integers, output any one of them.

You are given TT test cases; solve each of them.

给你两个整数 NN 和 DD,均至少为 22。

在不超过 NN 的正整数中,找出一个不是 DD 的倍数的数,使其正因数个数最多。若存在多个满足条件的数,输出其中任意一个即可。

你将得到 TT 组测试数据;请对每组数据分别求解。

输入格式

The input is given from Standard Input in the following format:

TT
case1\text{case}_1
case2\text{case}_2
⋮\vdots
caseT\text{case}_T

Here, casei\text{case}_i represents the ii-th test case, and is given in the following format:

NN DD

输入从标准输入中按以下格式给出:

TT
case1\text{case}_1
case2\text{case}_2
⋮\vdots
caseT\text{case}_T

其中,casei\text{case}_i 表示第 ii 个测试用例,其格式如下:

NN DD

输出格式

Output TT lines. The ii-th line should contain the answer for the ii-th test case.

输出 TT 行。第 ii 行应包含第 ii 个测试用例的答案。

输入输出样例

  • 输入#1

    4
    10 2
    17 4
    2026 919
    1000000000000 48

    输出#1

    9
    15
    1680
    843291048600

说明/提示

Sample 1 Explanation:
The positive integers at most 1010 that are not multiples of 22 are the five integers 1,3,5,7,91, 3, 5, 7, 9, and the numbers of their positive divisors are 1,2,2,2,31, 2, 2, 2, 3, respectively. Therefore, output 99 for the first test case.

For the second test case, besides 1515 in the sample output, outputting any of 6,10,146, 10, 14 is also accepted.

Constraints

  • 1≤T≤101 \leq T \leq 10
  • 2≤D≤N≤10182 \leq D \leq N \leq 10^{18}
  • All input values are integers.

样例 1 解释:
不超过 1010 的正整数中,不是 22 的倍数的数共有五个:1,3,5,7,91, 3, 5, 7, 9;它们各自的正因数个数分别为 1,2,2,2,31, 2, 2, 2, 3。因此,第一个测试用例的输出为 99。

对于第二个测试用例,除样例输出中的 1515 外,输出 6,10,146, 10, 14 中的任意一个也被接受。

约束条件

  • 1≤T≤101 \leq T \leq 10
  • 2≤D≤N≤10182 \leq D \leq N \leq 10^{18}
  • 所有输入值均为整数。

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

首页