Vojnici - Državno
This year, the Secret Committee has received an assignment from the serbian military to write a small program that will aid the army in making the best infantry formation possible in various circumstances. However, the Secret Committee is far too busy preparing this year's Nationals, so they have asked you to write this program, and you will get points at the nationals in return.
The task is to distribute N soldiers into R rows, such that there are [] soldiers in each row. The distance between each two neighbouring soldiers soldiers per row is equal, and the distance between neighbouring rows is also equal. Formally, we are to distribute the soldiers in a grid of size R x C, such that in each point (x, y), where (1 ≤ x ≤ R, 1 ≤ y ≤ C) there is exactly one soldier.
The formation is better if the soldiers can see each other better. If we let V(x,y) be the number of soldiers that the soldier situated in the point (x, y) can see, then the sum
\Huge{S = \sum_{1\leq x\leq R, 1\leq y\leq C} V(x,y)}
should be maximized. Two soldiers can see each other if there is no other soldier located between them on the line that joins their locations together.
For a given number of soldiers N you need to determine R and C such that the sum S is maximized, and that maximal sum as well.
If there are multiple correct solutions, print any one of them.
[c]12
Output:
3 4 98Explanation: The possible formations of soldiers are 1 x 12, 2 x 6, 3 x 4, 4 x 3, 6 x 2 and 12 x 1. The formations 3 x 4 and 4 x 3 have the maximal sum of 98.
4Output:
2 2 125Output:
5 1 8Submit solution
Coming laterThe grading service will be connected in a later migration step. You can inspect the task and your previous results now.