結果

問題 No.2526 Kth Not-divisible Number
ユーザー bluebery1001bluebery1001
提出日時 2023-11-03 21:42:31
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 680 ms / 2,000 ms
コード長 381 bytes
コンパイル時間 542 ms
コンパイル使用メモリ 81,896 KB
実行使用メモリ 76,908 KB
最終ジャッジ日時 2023-11-03 21:42:58
合計ジャッジ時間 7,346 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
53,740 KB
testcase_01 AC 36 ms
53,740 KB
testcase_02 AC 32 ms
53,740 KB
testcase_03 AC 650 ms
76,096 KB
testcase_04 AC 680 ms
76,096 KB
testcase_05 AC 635 ms
76,096 KB
testcase_06 AC 599 ms
76,096 KB
testcase_07 AC 615 ms
76,096 KB
testcase_08 AC 618 ms
76,908 KB
testcase_09 AC 652 ms
76,768 KB
testcase_10 AC 624 ms
76,440 KB
testcase_11 AC 576 ms
76,440 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 = 5000000000000000000
    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