1300 – K번째 수

문제

https://www.acmicpc.net/problem/1300

풀이

코드

def answer():
  global n, k
  start, end, ans = (1, n*n, 0)
  while(start <= end):
    mid, nth = ((start+end)//2, 0)
    for i in range(1, n+1):
      if mid//i == 0: break
      nth += min(n, mid//i)
    if k <= nth: ans, end = (mid, mid-1)
    else: start = mid+1
  print(ans)
   
n = int(input())
k = int(input())
answer()

Leave a Reply

Your email address will not be published.