結果

問題 No.2526 Kth Not-divisible Number
ユーザー flygon
提出日時 2023-11-03 21:28:40
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 545 bytes
コンパイル時間 547 ms
コンパイル使用メモリ 82,292 KB
実行使用メモリ 79,048 KB
最終ジャッジ日時 2024-09-25 19:12:37
合計ジャッジ時間 6,502 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 6 WA * 5
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
sys.setrecursionlimit(5*10**5)
input = sys.stdin.readline
from collections import defaultdict, deque, Counter
from heapq import heappop, heappush
from bisect import bisect_left, bisect_right
from math import gcd

def sol():
    a,b,k = map(int,input().split())
    ab = a*b//gcd(a,b)
    l = 0
    r = 2*10**18
    for i in range(70):
        m = (l+r)//2
        cnt = m-m//a-m//b+m//ab
        if cnt <= k:
            l = m
        else:
            r = m
    print(*[l])
    return 


T = int(input())
for i in range(T):
    sol()
0