結果

問題 No.2526 Kth Not-divisible Number
ユーザー MottchanMottchan
提出日時 2023-11-03 21:59:05
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 1,079 bytes
コンパイル時間 83 ms
コンパイル使用メモリ 11,844 KB
実行使用メモリ 10,248 KB
最終ジャッジ日時 2023-11-03 21:59:13
合計ジャッジ時間 4,104 ms
ジャッジサーバーID
(参考情報)
judge13 / judge10
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

import sys
sys.setrecursionlimit(5*10**5)
input = sys.stdin.readline
sys.set_int_max_str_digits(0)
from collections import defaultdict, deque, Counter
from heapq import heappop, heappush
from bisect import bisect_left, bisect_right
from math import gcd, lcm, factorial, perm, comb
from itertools import product, permutations
#重複あり:list(product(list('123'),repeat = 2)),重複なし:list(permutations(list('123')))
MOD = 998244353

def judge(a,b,k,m):
    kk = m - ((m//a + m//b) - m//lcm(a,b))
    if kk <= k:
        return 1
    else:
        return 0

def sol():
    a,b,k = map(int,input().split())
    ok=0
    ng=2*10**18
    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