Editorial for VMSS '15 #1 - Senpai, Help Me
                Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.
Submitting an official solution before solving the problem yourself is a bannable offence.
                Submitting an official solution before solving the problem yourself is a bannable offence.
Author:
The question asks us to create the rectangle with the shortest perimeter that has an area of exactly  and with integer side lengths.
Some of you may know the equation . This proves that in order to optimize perimeter length to area, we want 
 to be as low as possible, thus the square is the most efficient rectangle perimeter to area wise. Now obviously not every area has integer square root side lengths, so we want to get it as close to the square root as possible.
To start off, let's suppose , and keep decrementing 
 until 
 is an integer. In other words, 
 is divisible by 
. To check for divisibility in 
 time, we will use the modulo (
%) operator.
Final complexity: 
Comments