結果

問題 No.2526 Kth Not-divisible Number
ユーザー navel_tosnavel_tos
提出日時 2023-11-04 13:52:25
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 465 bytes
コンパイル時間 197 ms
コンパイル使用メモリ 81,880 KB
実行使用メモリ 85,128 KB
最終ジャッジ日時 2023-11-04 13:52:29
合計ジャッジ時間 4,443 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
57,984 KB
testcase_01 AC 38 ms
53,636 KB
testcase_02 AC 38 ms
53,636 KB
testcase_03 TLE -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#yukicoder411B

gcd=lambda x,y: gcd(y,x%y) if x%y else y
def solve(A,B,K):
    #二分探索を行う  値midはAでもBでも割り切れない正整数をK個以上有するか?
    ok,ng=10**19,0
    while abs(ok-ng)>1:
        mid=(ok+ng)//2; cnt=mid
        cnt-=mid//A; cnt-=mid//B; cnt+=mid//(A*B//gcd(A,B))
        ok,ng=(mid,ng) if cnt>=K else (ok,mid)
    return ok

for _ in range(int(input())):
    A,B,K=map(int,input().split()); print(solve(A,B,K))
0