VMSS '15 #1 - Senpai, Help Me

View as PDF

Submit solution


Points: 5
Time limit: 1.0s
Memory limit: 16M

Authors:
Problem type

The Service Club is famous in Sōbu High School for their ability to find the optimal solution to problems, albeit not always the prettiest. One day, Isshiki Iroha, the student council president, goes to the Service Club to ask for help with student council work again. To Hikigaya Hachiman and Yukinoshita Yukino's dismay, Yuigahama Yui, being the nice girl that she is, offers to help her.

Your job is to help the Service Club solve the student council's job, as Hikigaya is too lazy to do it himself and Yukinoshita Yukino is currently busy for some reason.

The student council is to create a rectangular flower garden given A units of soil then fence it off using the least amount of fencing to save as much of the student council budget as possible. What is the minimum amount of fencing required to fence off all the soil given that the side lengths of the garden must be integers?

Quote

Oh yeah? Good on you to notice. You're right, I am nice. I've been through all kinds of things in my life, but I haven't gone out for revenge on a single person at all. If I was any other normal person, this world would've ended already. You could even call me the savior of the world.

-Hikigaya Hachiman

Input Specification

The input will consist of 1 integer A (1 \le A \le 1\,000\,000), the amount of soil the student council is given.

Output Specification

Output P, the minimum amount of fencing required to fence off the garden.

Sample Input 1

16

Sample Output 1

16

Explanation for Sample Output 1

4 \times 4 has smallest perimeter P = 4+4+4+4 = 16.

Sample Input 2

90

Sample Output 2

38

Explanation for Sample Output 2

9 \times 10 has smallest perimeter P = 9+10+9+10 = 38.


Comments


  • -4
    zys5945  commented on Sept. 23, 2015, 2:18 a.m.

    Is this a math contest?


    • 15
      Xyene  commented on Sept. 23, 2015, 3:53 p.m.

      Yes.