結果

問題 No.2526 Kth Not-divisible Number
ユーザー 👑 SPD_9X2SPD_9X2
提出日時 2023-11-03 21:39:26
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 538 ms / 2,000 ms
コード長 506 bytes
コンパイル時間 145 ms
コンパイル使用メモリ 81,772 KB
実行使用メモリ 82,976 KB
最終ジャッジ日時 2023-11-03 21:39:34
合計ジャッジ時間 6,452 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
53,688 KB
testcase_01 AC 36 ms
53,688 KB
testcase_02 AC 36 ms
53,688 KB
testcase_03 AC 513 ms
82,740 KB
testcase_04 AC 538 ms
82,740 KB
testcase_05 AC 510 ms
82,744 KB
testcase_06 AC 538 ms
82,752 KB
testcase_07 AC 511 ms
82,740 KB
testcase_08 AC 501 ms
82,684 KB
testcase_09 AC 466 ms
82,504 KB
testcase_10 AC 493 ms
82,740 KB
testcase_11 AC 439 ms
82,976 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

"""

https://yukicoder.me/problems/no/2526



"""

import math
import sys
from sys import stdin

TT = int(stdin.readline())

ANS = []

for loop in range(TT):

    A,B,K = map(int,stdin.readline().split())
    lcm = A*B // math.gcd(A,B)

    L = -1
    R = 10**19

    while R-L != 1:

        M = (L+R)//2

        now = M
        now -= M // A
        now -= M // B
        now += M // lcm

        if now >= K:
            R = M
        else:
            L = M

    ANS.append(R)

print (*ANS,sep="\n")
0