Universal Cup Judging System

Universal Cup

Límite de tiempo: 1.0 s Límite de memoria: 1024 MB Puntuación total: 100 Hackeable ✓
Estadísticas

多重集係一種允許元素重複嘅集合。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.