結果

問題 No.2526 Kth Not-divisible Number
ユーザー lemondolemondo
提出日時 2023-11-03 22:02:19
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 454 bytes
コンパイル時間 739 ms
コンパイル使用メモリ 81,792 KB
実行使用メモリ 76,548 KB
最終ジャッジ日時 2023-11-03 22:02:27
合計ジャッジ時間 5,341 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 32 ms
53,708 KB
testcase_01 WA -
testcase_02 AC 34 ms
53,708 KB
testcase_03 AC 415 ms
76,192 KB
testcase_04 AC 438 ms
76,328 KB
testcase_05 AC 415 ms
76,196 KB
testcase_06 AC 412 ms
76,336 KB
testcase_07 AC 439 ms
76,196 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 347 ms
76,548 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 * 2+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