QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 512 MB Total points: 100

#21643. The problem of not providing large sample cases for multiple test cases

Statistics

The problem is kept simple. Since this is a Shandong provincial selection simulation contest, no large sample cases are provided; I hope everyone is doing fine.

For a given constant $K$, we define the "Shandong coefficient" of $N$ as the smallest divisor of $KN$ that is greater than $N$. For example, if $K=3$, the Shandong coefficient of $4$ is $6$.

Given a constant $K$ and a limit $LIM$, you need to calculate how many numbers have a Shandong coefficient no greater than $LIM$.

Input

The first line contains an integer $T$, representing the number of test cases. For each test case, the input consists of a single line containing two integers $LIM$ and $K$.

Output

For each test case, output a single integer on a new line representing the answer.

Constraints

  • For 20% of the data, $LIM \le 10^4$.
  • For 40% of the data, $LIM \le 10^6$.
  • For 100% of the data, $LIM \le 10^{12}$, $K \le 60$.
  • Since this is not an FJOI simulation, we inform you that $T \le 50$.

Examples

Input 1

5
114 5
1145 14
114514 19
11451419 19
23000000 23

Output 1

53
746
49815
4981675
9842921

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.