ps | |
---|---|
링크 | acmicpc.net/… |
출처 | BOJ |
문제 번호 | 1300 |
문제명 | K번째 수 |
레벨 | 골드 3 |
분류 |
파라메트릭 서치 |
시간복잡도 | O(nlogn) |
인풋사이즈 | n<=10^5 |
사용한 언어 | Python |
제출기록 | 33860KB / 472ms |
최고기록 | 228ms |
해결날짜 | 2021/06/04 |
태그 |
"""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()