[Problem solving] BJ2869 달팽이는 오르고 싶다

less than 1 minute read

BJ2869

problem name: 달팽이는 오르고 싶다

actually, really easy one. first time, I did fail.
I got timeout.. becuase, I like newbie, although I saw input size, I did use while Loop…..

while-loop break out time out!!!!

point of solution is that how to treat last day.

every one can think that climb - down.. i call this as ‘diff’.

if height is divided by diff, it might be not solution.

you have to think how to treat last day!!!

in my case, first i got height of tree - climb, then divided by diff.

var day = (height of tree - down) / (climb - down)
if day is Int 
then return day
else
//need one more day
then return day+1

end

Tags:

Categories:

Updated:

Leave a comment