結果

問題 No.2526 Kth Not-divisible Number
ユーザー Navier_BoltzmannNavier_Boltzmann
提出日時 2023-11-08 04:47:13
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 530 bytes
コンパイル時間 276 ms
コンパイル使用メモリ 81,868 KB
実行使用メモリ 77,084 KB
最終ジャッジ日時 2023-11-08 04:47:22
合計ジャッジ時間 9,032 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 48 ms
55,732 KB
testcase_01 WA -
testcase_02 AC 44 ms
55,732 KB
testcase_03 AC 954 ms
76,812 KB
testcase_04 AC 948 ms
76,812 KB
testcase_05 AC 975 ms
76,812 KB
testcase_06 AC 904 ms
76,692 KB
testcase_07 AC 889 ms
76,692 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 553 ms
77,084 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import *
from functools import *
from itertools import *
from heapq import *
import sys,math
input = sys.stdin.buffer.readline

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 = (1<<60)
    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