結果

問題 No.2526 Kth Not-divisible Number
ユーザー MottchanMottchan
提出日時 2023-11-03 21:54:04
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 857 bytes
コンパイル時間 775 ms
コンパイル使用メモリ 81,828 KB
実行使用メモリ 139,132 KB
最終ジャッジ日時 2023-11-03 21:54:31
合計ジャッジ時間 5,137 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 37 ms
55,740 KB
testcase_03 TLE -
testcase_04 TLE -
testcase_05 TLE -
testcase_06 TLE -
testcase_07 TLE -
testcase_08 TLE -
testcase_09 TLE -
testcase_10 TLE -
testcase_11 TLE -
権限があれば一括ダウンロードができます

ソースコード

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 judge(a,b,k,m):
    kk = m - ((m//a + m//b) - m//(a*b))
    if kk <= k:
        return 1
    else:
        return 0

def sol():
    a,b,k = map(int,input().split())
    ok=0
    ng=10**27
    while ng-ok>1:
        mid=(ng+ok)//2
        if judge(a,b,k,mid):
            ok=mid
        else:
            ng=mid
    print(ok)

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



#100のうち5の倍数は20個、100のうち3の倍数は33個
#53個から15の倍数は除く6個、47個が3と5の倍数
#2分探索で行けるのでは
#正整数nがK番目のより大きいか小さいか。
#(n - (n//a + n//b - n//(a*b)))->K
0