結果

問題 No.2526 Kth Not-divisible Number
ユーザー rlangevinrlangevin
提出日時 2023-11-03 21:27:16
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 797 ms / 2,000 ms
コード長 441 bytes
コンパイル時間 479 ms
コンパイル使用メモリ 81,836 KB
実行使用メモリ 76,192 KB
最終ジャッジ日時 2023-11-03 21:27:32
合計ジャッジ時間 7,666 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
53,756 KB
testcase_01 AC 32 ms
53,756 KB
testcase_02 AC 31 ms
53,756 KB
testcase_03 AC 784 ms
76,064 KB
testcase_04 AC 797 ms
76,192 KB
testcase_05 AC 784 ms
76,068 KB
testcase_06 AC 748 ms
76,192 KB
testcase_07 AC 797 ms
76,148 KB
testcase_08 AC 528 ms
75,860 KB
testcase_09 AC 492 ms
76,072 KB
testcase_10 AC 590 ms
76,064 KB
testcase_11 AC 172 ms
76,128 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
from math import gcd

def check(m, a, b):
    val = m
    val -= m // a + m // b
    lcm = a * b // gcd(a, b)
    return val + m // lcm
    

T = int(input())
for _ in range(T):
    A, B, K = map(int, input().split())
    yes = 3 * K
    no = 0
    while yes - no != 1:
        mid = (yes + no)//2
        if check(mid, A, B) >= K:
            yes = mid
        else:
            no = mid
    print(yes)
0