목차

K번째 수

ps
링크acmicpc.net/…
출처BOJ
문제 번호1300
문제명K번째 수
레벨골드 3
분류

파라메트릭 서치

시간복잡도O(nlogn)
인풋사이즈n<=10^5
사용한 언어Python
제출기록33860KB / 472ms
최고기록228ms
해결날짜2021/06/04
태그

21단계

풀이

코드

"""Solution code for "BOJ 1300. K번째 수".

- Problem link: https://www.acmicpc.net/problem/1300
- Solution link: http://www.teferi.net/ps/problems/boj/1300
"""

from teflib import algorithm


def main():
    def is_greater_than_k_nums(num):
        low = (num - 1) // N 
        smaller_num_count = low * N
        smaller_num_count += sum((num - 1) // i for i in range(low + 1, N + 1))
        return smaller_num_count >= k

    N = int(input())
    k = int(input())

    print(algorithm.binary_search(0, k + 10, is_greater_than_k_nums) - 1)


if __name__ == '__main__':
    main()