結果

問題 No.2526 Kth Not-divisible Number
ユーザー bluebery1001bluebery1001
提出日時 2023-11-03 21:41:31
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 382 bytes
コンパイル時間 176 ms
コンパイル使用メモリ 81,812 KB
実行使用メモリ 78,080 KB
最終ジャッジ日時 2023-11-03 21:41:54
合計ジャッジ時間 19,673 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
53,732 KB
testcase_01 AC 33 ms
53,732 KB
testcase_02 AC 36 ms
53,732 KB
testcase_03 AC 1,974 ms
77,788 KB
testcase_04 AC 1,998 ms
77,784 KB
testcase_05 TLE -
testcase_06 AC 1,976 ms
77,764 KB
testcase_07 TLE -
testcase_08 TLE -
testcase_09 TLE -
testcase_10 TLE -
testcase_11 AC 1,987 ms
77,804 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import math
t=int(input())
for i in range(t):
    a,b,k = map(int,input().split())
    lc = (a*b)//math.gcd(a,b)
    ok = k
    ng = 20000000000000000000
    while abs(ok-ng)>1:
        mid = (ok+ng)//2
        cna = mid//a
        cnb = mid//b
        cnab = mid//(lc)
        if (mid-(cna+cnb-cnab)<=k):ok=mid
        else:ng = mid
    while ok%a==0 or ok%b==0:ok-=1
    print(ok)
0