結果

問題 No.2526 Kth Not-divisible Number
ユーザー chineristACchineristAC
提出日時 2023-11-03 22:23:42
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,014 bytes
コンパイル時間 242 ms
コンパイル使用メモリ 81,816 KB
実行使用メモリ 83,120 KB
最終ジャッジ日時 2023-11-03 22:23:49
合計ジャッジ時間 5,840 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 55 ms
66,852 KB
testcase_01 WA -
testcase_02 AC 52 ms
66,852 KB
testcase_03 AC 492 ms
82,504 KB
testcase_04 AC 466 ms
82,504 KB
testcase_05 AC 466 ms
82,484 KB
testcase_06 AC 486 ms
82,484 KB
testcase_07 AC 470 ms
82,508 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 373 ms
83,120 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
from itertools import permutations
from heapq import heappop,heappush
from collections import deque
import random
import bisect

input = lambda :sys.stdin.readline().rstrip()
mi = lambda :map(int,input().split())
li = lambda :list(mi())

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    return (g1[n] * g2[r] % mod) * g2[n-r] % mod


mod = 998244353
N = 2*10**5
g1 = [1]*(N+1)
g2 = [1]*(N+1)
inverse = [1]*(N+1)

for i in range( 2, N + 1 ):
    g1[i]=( ( g1[i-1] * i ) % mod )
    inverse[i]=( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2[i]=( (g2[i-1] * inverse[i]) % mod )
inverse[0]=0

from math import gcd

def solve(A,B,K):
    lcm = A*B//gcd(A,B)
    def cond(x):
        tmp = x - x//A - x//B + x//lcm
        return K <= tmp
    
    ok = 10**18 + 2 * 10**10
    ng = 0
    while ok-ng>1:
        mid = (ok+ng)//2
        if cond(mid):
            ok = mid
        else:
            ng = mid
    return ok

for _ in range(int(input())):
    a,b,k = mi()
    print(solve(a,b,k))
0