結果
| 問題 | No.2526 Kth Not-divisible Number |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-11-03 21:55:28 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 857 bytes |
| 記録 | |
| コンパイル時間 | 158 ms |
| コンパイル使用メモリ | 12,672 KB |
| 実行使用メモリ | 17,952 KB |
| 最終ジャッジ日時 | 2024-09-25 20:08:24 |
| 合計ジャッジ時間 | 4,086 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 1 |
| other | AC * 1 WA * 1 TLE * 1 -- * 8 |
ソースコード
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**20
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