No.2526 Kth Not-divisible Number
タグ : / 解いたユーザー数 160
作問者 :
srjywrdnprkt
/ テスター :
👑 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もしくは右上の雲マークをクリックしてアカウントを作成してください。