結果

問題 No.2526 Kth Not-divisible Number
ユーザー KoiKoi
提出日時 2023-11-03 21:33:28
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 384 bytes
コンパイル時間 193 ms
コンパイル使用メモリ 81,868 KB
実行使用メモリ 79,812 KB
最終ジャッジ日時 2023-11-03 21:33:35
合計ジャッジ時間 4,618 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
53,692 KB
testcase_01 WA -
testcase_02 AC 36 ms
53,692 KB
testcase_03 AC 401 ms
79,312 KB
testcase_04 AC 398 ms
79,308 KB
testcase_05 AC 424 ms
79,316 KB
testcase_06 AC 401 ms
79,300 KB
testcase_07 AC 420 ms
79,304 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import math
T=int(input())
answers=[]
for i in range(T):
    A,B,K=map(int,input().split())
    c=math.lcm(A,B)
    s=c-(c//A-1)-(c//B-1)-1
    ans=0
    ans+=(K//s)*c
    K=K%s
    ok=c
    ng=0
    while (ok-ng)>1:
        m=(ok+ng)//2
        if(m-m//A-m//B>=K):
            ok=m
        else:
            ng=m
    ans+=ok
    answers.append(ans)
for ans in answers:
    print(ans)
0