結果

問題 No.2526 Kth Not-divisible Number
ユーザー lemondolemondo
提出日時 2023-11-03 22:03:02
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 512 ms / 2,000 ms
コード長 454 bytes
コンパイル時間 199 ms
コンパイル使用メモリ 81,824 KB
実行使用メモリ 76,592 KB
最終ジャッジ日時 2023-11-03 22:03:17
合計ジャッジ時間 6,226 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,736 KB
testcase_01 AC 36 ms
53,736 KB
testcase_02 AC 38 ms
53,736 KB
testcase_03 AC 486 ms
76,244 KB
testcase_04 AC 493 ms
76,372 KB
testcase_05 AC 485 ms
76,236 KB
testcase_06 AC 512 ms
76,372 KB
testcase_07 AC 487 ms
76,236 KB
testcase_08 AC 487 ms
76,180 KB
testcase_09 AC 411 ms
76,528 KB
testcase_10 AC 472 ms
76,440 KB
testcase_11 AC 421 ms
76,592 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return list(map(int, input().split()))
sys.setrecursionlimit(10**9)

from math import gcd
T = int(input())
for _ in range(T):
    A, B, K = mapint()
    lc = A*B//gcd(A, B)
    l = 0
    r = 10**18 * 6+1
    while l+1<r:
        tar = (l+r)//2
        cnt = tar - tar//A - tar//B + tar//lc
        if(cnt >= K):
            r = tar
        else:
            l = tar
    print(r)

0