Soldiers in row

“How to arrange 10 soldiers in 5 rows of 4 soldiers each?”

Although this problem looks impossible, this is a solution:

(16,16)

(8,8)8

(8,16)0.40(8,16) (0.3915,10.4721)0.41(0.3915,10.4721) (15.6085,10.4721)0.42(15.6085,10.4721) (3.2977,1.5279)0.43(3.2977,1.5279) (12.7023,1.5279)0.44(12.7023,1.5279)

(8,4.95)0.45(8,4.95) (10.9,7.05)0.46(10.9,7.05) (5.1,7.05)0.47(5.1,7.05) (9.8,10.45)0.48(9.8,10.45) (6.2,10.45)0.49(6.2,10.45)

Input

Input consists of several cases, each with a natural number nn between 2 and 10810^8.

Output

For every case, we must arrange nn soldiers in rows, as follows: In a circumference, we choose xx different points, where xx is odd and at least 3. Then, we draw xx straight segments between different pairs of those xx points. At the end, we can place one soldier on every resulting intersection, those produced at the ends of the segments included.

For every given nn, print the minimum xx that allows arranging at least nn soldiers.

Problem information

Author: Unknown
Translator: Salvador Roura

Generation: 2026-01-25T11:55:32.611Z

© Jutge.org, 2006–2026.
https://jutge.org