CF1099B.Squares and Segments

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Little Sofia is in fourth grade. Today in the geometry lesson she learned about segments and squares. On the way home, she decided to draw nn squares in the snow with a side length of 11 . For simplicity, we assume that Sofia lives on a plane and can draw only segments of length 11 , parallel to the coordinate axes, with vertices at integer points.

In order to draw a segment, Sofia proceeds as follows. If she wants to draw a vertical segment with the coordinates of the ends (x,y)(x, y) and (x,y+1)(x, y+1) . Then Sofia looks if there is already a drawn segment with the coordinates of the ends (x,y)(x', y) and (x,y+1)(x', y+1) for some xx' . If such a segment exists, then Sofia quickly draws a new segment, using the old one as a guideline. If there is no such segment, then Sofia has to take a ruler and measure a new segment for a long time. Same thing happens when Sofia wants to draw a horizontal segment, but only now she checks for the existence of a segment with the same coordinates xx , x+1x+1 and the differing coordinate yy .

For example, if Sofia needs to draw one square, she will have to draw two segments using a ruler:

After that, she can draw the remaining two segments, using the first two as a guide:

If Sofia needs to draw two squares, she will have to draw three segments using a ruler:

After that, she can draw the remaining four segments, using the first three as a guide:

Sofia is in a hurry, so she wants to minimize the number of segments that she will have to draw with a ruler without a guide. Help her find this minimum number.

输入格式

The only line of input contains a single integer nn ( 1n1091 \le n \le 10^{9} ), the number of squares that Sofia wants to draw.

输出格式

Print single integer, the minimum number of segments that Sofia will have to draw with a ruler without a guide in order to draw nn squares in the manner described above.

输入输出样例

  • 输入#1

    1
    

    输出#1

    2
    
  • 输入#2

    2
    

    输出#2

    3
    
  • 输入#3

    4
    

    输出#3

    4
    
首页