Minimum Size Of a board

3.1

8 votes
, Basic Programming, Algorithms
Problem

You are given n pieces and a m×m board. The rows and columns are numbered from 1 to m. A cell on the intersection of the rth row and cth column is denoted as as (r,c).

The game's goal is to place n pieces numbered from 1 to n on the board. The ith piece lies on (ri,ci) while the following rule must be satisfied:

For all pairs of pieces i and j,|rirj|k or |cicj|k. Here, |x| denotes the absolute value of x.

Determine the smallest size of the board m×m on which you can put n pieces according to the rules.

Input format

The only line contains two integer, n(1n1000000) denoting the number of pieces and k(1k1000000).

Output format

Print a single integer denoting the minimum value of m denoting the length of sides of the suitable board.

Time Limit: 5
Memory Limit: 256
Source Limit:
Explanation
1   2   3
         
4   5    
         
         

 

Editor Image

?