結果

問題 No.2526 Kth Not-divisible Number
ユーザー flygonflygon
提出日時 2023-11-03 21:32:35
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 543 ms / 2,000 ms
コード長 544 bytes
コンパイル時間 211 ms
コンパイル使用メモリ 81,884 KB
実行使用メモリ 78,488 KB
最終ジャッジ日時 2023-11-03 21:32:45
合計ジャッジ時間 6,659 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
55,832 KB
testcase_01 AC 41 ms
55,832 KB
testcase_02 AC 41 ms
55,832 KB
testcase_03 AC 522 ms
76,984 KB
testcase_04 AC 529 ms
76,980 KB
testcase_05 AC 530 ms
77,024 KB
testcase_06 AC 543 ms
76,980 KB
testcase_07 AC 529 ms
76,984 KB
testcase_08 AC 514 ms
76,964 KB
testcase_09 AC 435 ms
76,816 KB
testcase_10 AC 535 ms
76,932 KB
testcase_11 AC 494 ms
78,488 KB
権限があれば一括ダウンロードができます

ソースコード

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 = 4*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(*[r])
    return 


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