测评会员优惠活动进行中 · 开通 VIP,有效期内测评不限次 VIP 优惠中 · 测评不限次 立即查看

A11235. Lazy Security Guard

编程题 普及/提高-

题目描述

Your security guard friend recently got a new job at a new security company. The company requires him to patrol an area of the city encompassing exactly $N$ city blocks, but they let him choose which blocks. That is, your friend must walk the perimeter of a region whose area is exactly $N$ blocks. Your friend is quite lazy and would like your help to find the shortest possible route that meets the requirements. The city is laid out in a square grid pattern, and is large enough that for the sake of the problem it can be considered infinite.

输入格式

Input will consist of a single integer $N$ ( $1<=N<=10^{6}$ ), the number of city blocks that must be enclosed by the route.

输出格式

Print the minimum perimeter that can be achieved.

输入输出样例

输入 #1
4
输出 #1
8
输入 #2
11
输出 #2
14
输入 #3
22
输出 #3
20

说明/提示

Here are some possible shapes for the examples:

![](/uploads/acgo/image/c4fc26ac042bd68b_ab794f1f65ae.jpeg)
上一题 去做题 下一题