Universal Cup Judging System

Universal Cup

Süre Sınırı: 1.0 s Bellek Sınırı: 1024 MB Toplam puan: 100 Hack'lenebilir ✓
İstatistikler

多重集是一種允許元素重複的集合。Panda 有一個整數多重集 $S$ 和三個整數 $n, k, m$。最初,$S = \{1, 2, \dots, n\}$。Panda 想要對 $S$ 進行一系列操作。在每次操作中:從目前的 $S$ 中選擇一個整數子集,使得該子集中所有整數的最大公因數(GCD)恰好為 $k$,然後從 $S$ 中移除所有選中的整數。

每次操作中必須至少選擇一個整數。一個整數集合的最大公因數(GCD)是整除該集合中每個整數的最大正整數 $g$。例如,$\gcd(12, 16) = 4$,$\gcd(6, 9, 12) = 3$,且 $\gcd(6, 10, 15) = 1$。請記住,單個整數的 GCD 就是該整數本身。

在第一次操作之前,Panda 可以選擇 $S$ 中至多 $m$ 個整數並修改它們的值。每個被選中的整數可以被修改為 $1$ 到 $n$ 之間的任意值。請注意,此修改允許 $S$ 包含重複的值。

你需要幫助 Panda 求出他能成功執行的最大操作次數。

輸入

第一行包含一個整數 $T$($1 \le T \le 10^4$),表示測試資料的組數。

對於每組測試資料,輸入為一行,包含三個整數 $n, k, m$($1 \le k \le n \le 10^{18}$,$0 \le m \le n$),其中 $n$ 是初始多重集的上限,$k$ 是子集要求的 GCD,而 $m$ 是最多可以修改的值的個數。

輸出

對於每組測試資料,在一行中輸出一個整數,表示可以成功執行的最大操作次數。

範例

範例輸入 1

2
4 1 0
5 3 1

範例輸出 1

2
2

提示

對於第一組測試資料,一種可能的方案包含兩次操作:

  1. 選擇子集 $\{1, 4\}$ 並將其移除。
  2. 選擇子集 $\{2, 3\}$ 並將其移除。

對於第二組測試資料,一種方案是將 $1$ 修改為 $3$,然後執行兩次操作:

  1. 選擇子集 $\{3\}$ 並將其移除。
  2. 選擇子集 $\{3\}$ 並將其移除。

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.