Squares and Segments

time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

 

 

 

output

standard output

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 x′x′. 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.

Input

The only line of input contains a single integer nn (1≤n≤1091≤n≤109), the number of squares that Sofia wants to draw.

Output

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.

Examples

input

1

output

2

input

2

output

3

input

4

output

4

 

 

At the beginning of this question, the idea is to divide the input data into four parts. The odd and even numbers are divided into two parts. The two parts are divided into two parts, prime and non-prime. In doing so, the example is Exceeded, but this idea is not the optimal solution!

The reason is that the graphics that have been solidified into the final form must be rectangular, but it is not;

 

In this order, the numbers obtained are 1, 2, and 4, respectively.

Now comes a question, if I type 5, how do I get it?

 

This is six, it seems very reasonable, but it is not.

 

Follow this method to add 1 but the results are more optimized!

 

#include<stdio.h>
#include<algorithm>
using namespace std;
int main()
{
    long long int x;
    long long a=1,b=1;
    long long mm=0;
    scanf("%lld",&x);
    for(long long int i=1;i<=x;++i)
    {
        if(a*b>=x)
        {
           mm=a+b;
           break;
        }
        if(a<b) a++;
        else b++;
    }

    printf("%lld",mm);
    return 0;
}

 

2019.01.06 CodeForce

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值