
메모리: 113112 KB, 시간: 112 ms
수학
땅 위에 달팽이가 있다. 이 달팽이는 높이가 V미터인 나무 막대를 올라갈 것이다.
달팽이는 낮에 A미터 올라갈 수 있다. 하지만, 밤에 잠을 자는 동안 B미터 미끄러진다. 또, 정상에 올라간 후에는 미끄러지지 않는다.
달팽이가 나무 막대를 모두 올라가려면, 며칠이 걸리는지 구하는 프로그램을 작성하시오.
첫째 줄에 세 정수 A, B, V가 공백으로 구분되어서 주어진다. (1 ≤ B < A ≤ V ≤ 1,000,000,000)
첫째 줄에 달팽이가 나무 막대를 모두 올라가는데 며칠이 걸리는지 출력한다.
#https://www.acmicpc.net/problem/2869
#달팽이는 올라가고 싶다
#2869
import sys
input = sys.stdin.readline
a, b, v = map(int, input().split())
result = 0 #
day = 0
# while result <= v:
# day += 1
# result = result + a
# if result >=v:
# break
# else:
# result = result - b
# # print(day)
day = ((v-a) / (a-b)) +1
result = int(day)
# if day == result:
# print(result)
# else:
# print(result+1)
if day%1 == 0 :
print(int(day))
else:
print(int(day+1))
#해당 코드에서 while문의 조건식인 result >= v에서 result의 초기값이 0이기 때문에 조건식이 거짓(False)이 되어 반복문이 실행되지 않습니다. 따라서 day의 초기값인 0이 그대로 출력되게 됩니다.
#https://www.acmicpc.net/problem/2869
#달팽이는 올라가고 싶다
#2869
import sys
input = sys.stdin.readline
a, b, v = map(int, input().split())
def fun():
day = ((v-a)/(a-b)) + 1
result = int(day)
if day%1 == 0:
print(result)
else:
print(result + 1)
fun()
# result = 0 #
# day = 0
# # while result <= v:
# # day += 1
# # result = result + a
# # if result >=v:
# # break
# # else:
# # result = result - b
# # # print(day)
# day = ((v-a) / (a-b)) +1
# result = int(day)
# # if day == result:
# # print(result)
# # else:
# # print(result+1)
# if day%1 == 0 :
# print(int(day))
# else:
# print(int(day+1))