https://www.acmicpc.net/problem/4796
import sys
fast_input = sys.stdin.readline
fast_print = sys.stdout.write
test_cases = {}
idx = 1
while True:
temp_line = sys.stdin.readline().rstrip()
if temp_line == "0 0 0":
break
test_cases[idx] = temp_line.split(" ")
idx += 1
for case_idx, test_case in test_cases.items():
limit_days = int(test_case[0])
consecutive_days = int(test_case[1])
vacation_days = int(test_case[2])
use_days = 0
use_days += (vacation_days // consecutive_days) * limit_days
vacation_days = vacation_days % consecutive_days
if vacation_days >= limit_days:
use_days += limit_days
else:
use_days += vacation_days
fast_print("Case " + str(case_idx) + ": " + str(use_days))
좀 더 스마트하게 바꿀 수 있다.
실제로 fast_input도 정의해놓고 사용하지 않았고..
쓸데없이 딕셔너리를 사용한것 같다.
하나의 while문 안에서 처리가 가능하다.
import sys
fast_input = sys.stdin.readline
fast_print = sys.stdout.write
i = 1
while True:
L, P, V = map(int, fast_input().split())
if L == 0 and P == 0 and V == 0:
break
else:
if V % P > L:
fast_print("Case " + str(i) + ": " + str(V // P * L + L))
else:
fast_print("Case " + str(i) + ": " + str(V // P * L + V % P))
i += 1