백준 2869번: 달팽이는 올라가고 싶다

danbibibi·2021년 10월 3일
0

문제

문제 바로가기> 백준 2869번: 달팽이는 올라가고 싶다

풀이

V-A를 한 이유는 마지막 날 달팽이는 떨어지지 않고 올라가기만 할 것이기 때문이다.

def solution():
    import sys
    A, B, V = map(int, sys.stdin.readline().rstrip().split())
    if (V-A)%(A-B)!=0: print((V-A)//(A-B)+2)
    else: print((V-A)//(A-B)+1)
solution()

코드 개선

다음과 같이 간단하게 작성할 수도 있다.

def solution():
    import sys
    A, B, V = map(int, sys.stdin.readline().rstrip().split())
    print((V-A)//(A-B)+1+(((V-A)%(A-B))!=0))
solution()
profile
블로그 이전) https://danbibibi.tistory.com

0개의 댓글