CF859B.Lazy Security Guard

入门

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

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.

你的保安朋友最近在一家新的安保公司找到了一份新工作。该公司要求他巡逻城市中恰好包含 N 个街区的区域,但允许他自己选择具体是哪些街区。也就是说,你的朋友必须沿一个面积恰好为 N 个街区的区域的周界行走。你的朋友非常懒惰,希望你能帮他找出满足要求的最短可能路线。城市呈正方形网格布局,且范围足够大,因此在本题中可将其视为无限大。

输入格式

Input will consist of a single integer N (1 ≤ N ≤ 106), the number of city blocks that must be enclosed by the route.

输入将包含一个整数 NN(1≤N≤1061 \leq N \leq 10^6),表示路线必须围住的城市街区数量。

输出格式

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:

以下是一些示例可能的形状:

输入解题思路,AI测评打分。不知道怎么写?

首页