z-pins
Little Z is keen to win in the upcoming round of programming competitions. Since his class has a lot good programmers, professor Dule has lot of troubles putting all their (competition) results on the big rounded billboard in the school hall.
The billboard has the perimeter so that it can fit exactly K square papers with competition results (with small overlap as professor Dule needs to stick more then one paper with one pin). Billboard is high enough to place all N square papers of the competition results. Dule always has troubles with using to much pins, so he wants you to help him to find optimal number of pins needed to put all the papers on the round billboard. All four corner of every list of paper must have exactly one pin (one pin can handle 1, 2, 3 or 4 papers).
6 10Output:
12Explanation: To put six papers on this billboard, professor need 12 pins, if he group them in 2 rows and 3 columns.
9 3Output:
12Explanation: To put the nine papers on billboard, professor again need 12 pins, but this time he must group them in 3 rows and 3 columns. He will close circle around the billboard to spare some pins.
Submit solution
Coming laterThe grading service will be connected in a later migration step. You can inspect the task and your previous results now.