859B.md (1209B)
1 Source: https://codeforces.com/problemset/problem/859/B 2 3 B. Lazy Security Guard 4 5 time limit per test 6 7 2 seconds 8 9 memory limit per test 10 11 256 megabytes 12 13 input 14 15 standard input 16 17 output 18 19 standard output 20 21 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. 22 23 Input 24 25 Input will consist of a single integer *N* (1 ≤ *N* ≤ 106), the number of city blocks that must be enclosed by the route. 26 27 Output 28 29 Print the minimum perimeter that can be achieved. 30 31 Examples 32 33 Input 34 35 ``` 36 4 37 ``` 38 39 Output 40 41 ``` 42 8 43 ``` 44 45 Input 46 47 ``` 48 11 49 ``` 50 51 Output 52 53 ``` 54 14 55 ``` 56 57 Input 58 59 ``` 60 22 61 ``` 62 63 Output 64 65 ``` 66 20 67 ``` 68 69 Note 70 71 Here are some possible shapes for the examples: 72 73 