MemSQL Start[c]UP 3.0 - Round 1
B
Lazy Security Guard
Codeforces
1000
原题
← AC →
翻译中…

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

翻译中…

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

翻译中…

Output

翻译中…

Print the minimum perimeter that can be achieved.

翻译中…

Note

翻译中…

Here are some possible shapes for the examples:

翻译中…

image

翻译中…

样例

Input #1
4
Output #1
8
InputCopy OutputCopy
Input #2
11
Output #2
14
InputCopy OutputCopy
Input #3
22
Output #3
20
InputCopy OutputCopy
题目信息
题号
859B
时间限制
2 s
内存限制
256 MB
标签
暴力
计算几何
数学

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。