Problems > K-th in the Times Table

K-th in the Times Table

Difficulty: 1800 4000 ms 128 MB

binary-search

In the N×N multiplication table (cell (i,j) holds i·j), print the K-th smallest value.

Input: one line with two integers N and K.

Output: the K-th smallest table value.

Constraints:

  • 1 ≤ N ≤ 3000
  • 1 ≤ K ≤ N²

Sample Tests

Input 1
3 5
Output 1
3
Input 2
1 1
Output 2
1

Read the Editorial

Discussion (opens after you solve — no spoilers before)

No comments yet.

Submit Your Solution

Log in or create a free account to run and submit code.