第 475 场 AtCoder Beginner Contest
G
因数很多
Has Many Divisors
AtCoder
⌀ 2360
原题
← F→

因数很多AI (CI翻译)

Problem Statement

题目描述

AI (CI翻译)

You are given integers $N$ and $D$, each at least $2$.

给定两个整数 $N$ 和 $D$,它们均至少为 $2$。AI (CI翻译)

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.

请从不超过 $N$ 且不是 $D$ 的倍数的正整数中,找出正因数个数最多的一个。如果有多个满足条件的正整数,输出其中任意一个即可。AI (CI翻译)

You are given $T$ test cases; solve each of them.

给定 $T$ 组测试数据,请分别求解每组数据。AI (CI翻译)

Constraints

约束条件

AI (CI翻译)
  • $1 \leq T \leq 10$
  • $2 \leq D \leq N \leq 10^{18}$
  • All input values are integers.
  • $1 \leq T \leq 10$
  • $2 \leq D \leq N \leq 10^{18}$
  • 所有输入值均为整数。
AI (CI翻译)

Input

输入格式

AI (CI翻译)

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

输入从标准输入按以下格式给出:AI (CI翻译)

T
\text{case}_1
\text{case}_2
\vdots
\text{case}_T

T
\text{case}_1
\text{case}_2
\vdots
\text{case}_T
AI (CI翻译)

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

其中,$\text{case}_i$ 表示第 $i$ 组测试数据,格式如下:AI (CI翻译)

N D

N D
AI (CI翻译)

Output

输出格式

AI (CI翻译)

Output $T$ lines. The $i$-th line should contain the answer for the $i$-th test case.

输出 $T$ 行。第 $i$ 行应包含第 $i$ 组测试数据的答案。AI (CI翻译)

样例

Input #1
4
10 2
17 4
2026 919
1000000000000 48
Output #1
9
15
1680
843291048600
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.
题目信息
题号
abc475_g
时间限制
2 s
内存限制
1024 MB

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(gpt-6.1-sol),如有出入请以原文为准。