問題一覧 > 通常問題

No.2526 Kth Not-divisible Number

レベル : / AI推定難易度 : 1100 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 160
作問者 : srjywrdnprkt / テスター : 👑 p-adic
お気に入りにしたユーザー ProblemId : 9461 / 自分の提出
問題文最終更新日: 2023-11-03 22:20:30
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 411 オムニバスコンテスト (順位表) の他の問題:

Problem Statement

You are given $T$ test cases.

In the $i$-th test case, you are given a positive integer $K_i$ and distinct positive integers $A_i,~B_i$, each at least $2$. Find the $K_i$-th smallest positive integer that is divisible by neither $A_i$ nor $B_i$.

Input

$T$
$A_1\ B_1\ K_1$
$\vdots$
$A_T\ B_T\ K_T$

All inputs are integers and satisfy the following constraints.

  • $1 \leq T \leq 10^5$
  • $2\leq A_i, B_i \leq 10^9$
  • $A_i\neq B_i$
  • $1\leq K_i \leq 10^{18}$

Output

Output $T$ lines. On the $i$-th line, output the answer to the $i$-th test case.

Sample

Sample 1
Input
5
3 5 7
10 20 1
18 12 100
314 159 2653
1000000000 999999999 1000000000000000000
Output
13
1
112
2677
1000000002000000004

Consider the case $i=1$. The positive integers divisible by neither $3$ nor $5$ are, in increasing order, $1,~2,~4,~7,~8,~11,~13,\cdots$. Therefore, the answer is $13$, which is the $7$-th smallest.

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。