結果

問題 No.2526 Kth Not-divisible Number
ユーザー Navier_BoltzmannNavier_Boltzmann
提出日時 2023-11-08 04:53:02
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,006 ms / 2,000 ms
コード長 568 bytes
コンパイル時間 414 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 76,892 KB
最終ジャッジ日時 2023-11-08 04:53:11
合計ジャッジ時間 9,340 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 46 ms
55,512 KB
testcase_01 AC 46 ms
55,512 KB
testcase_02 AC 47 ms
55,512 KB
testcase_03 AC 932 ms
76,528 KB
testcase_04 AC 926 ms
76,528 KB
testcase_05 AC 937 ms
76,528 KB
testcase_06 AC 1,001 ms
76,548 KB
testcase_07 AC 1,006 ms
76,548 KB
testcase_08 AC 715 ms
76,656 KB
testcase_09 AC 675 ms
76,676 KB
testcase_10 AC 770 ms
76,572 KB
testcase_11 AC 304 ms
76,892 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import *
from functools import *
from itertools import *
from heapq import *
import sys,math
input = sys.stdin.buffer.readline
# sys.maxsize = (1<<64) - 1
def answer():
    A,B,K = map(int,input().split())
    
    def is_ok(x):
        
        tmp = (x//A) + (x//B) - (x//(A*B//math.gcd(A,B)))
        
        return x-tmp >= K
        
    y = min((1<<62),K*A*B)
    x = K-1
    while y-x>1:
        mid = (y+x)//2
        if is_ok(mid):
            y = mid
        else:
            x = mid
    print(y)
for _ in range(int(input())):
    answer()
0