結果

問題 No.2526 Kth Not-divisible Number
ユーザー KoiKoi
提出日時 2023-11-03 21:43:28
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,972 ms / 2,000 ms
コード長 537 bytes
コンパイル時間 1,098 ms
コンパイル使用メモリ 81,848 KB
実行使用メモリ 85,088 KB
最終ジャッジ日時 2023-11-03 21:43:50
合計ジャッジ時間 20,059 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 33 ms
53,752 KB
testcase_01 AC 33 ms
53,752 KB
testcase_02 AC 35 ms
53,752 KB
testcase_03 AC 1,928 ms
84,832 KB
testcase_04 AC 1,921 ms
84,840 KB
testcase_05 AC 1,972 ms
84,844 KB
testcase_06 AC 1,899 ms
84,840 KB
testcase_07 AC 1,936 ms
84,844 KB
testcase_08 AC 1,921 ms
84,940 KB
testcase_09 AC 1,931 ms
84,808 KB
testcase_10 AC 1,939 ms
84,872 KB
testcase_11 AC 1,645 ms
85,088 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import math
T=int(input())
answers=[]
def solve(A,B,K):
    c=math.lcm(A,B)
    ng=0
    ok=10**19
    while (ok-ng)>1:
        m=(ok+ng)//2
        if(m-(m//B)-(m//A)+(m//c)>=K):
            ok=m
        else:
            ng=m
    return ok
def gutyoku(A,B,K):
    ans=0
    while K>0:
        ans+=1
        if(ans%A==0 or ans%B==0):
            continue
        else:
            K-=1
    return ans

for i in range(T):
    A,B,K=map(int,input().split())
    ans=solve(A,B,K)
    answers.append(ans)
for ans in answers:
    print(ans)
0