코딩테스트/백준 문제

[파이썬] 백준 5532번(브론즈4) : 방학 숙제

김뚱입니다 2025. 5. 19. 01:23

[문제]

문제 : 백준 5532번_방학 숙제

 

 

 

[코드]

import sys
input = sys.stdin.readline

inputs = [int(input().strip()) for _ in range(5)]
L, A, B, C, D = inputs
math, national_language = 0, 0

if not A % C == 0:
    math = A // C + 1
else:
    math = A // C

if not B % D == 0:
    national_language = B // D + 1
else:
    national_language = B // D

result = L - max(math, national_language)

print(result)

 

 

 

[리팩터링 코드]

import sys
import math
input = sys.stdin.readline

L, A, B, C, D = [int(input().strip()) for _ in range(5)]

math_days = math.ceil(A / C)
lang_days = math.ceil(B / D)

study_days = max(math_days, lang_days)
print(L - study_days)
  • 의미를 뚜렷하게 하기 위해 변수명 변경
  • math.ceil 이용해서 자동으로 반올림 되게 변경

 

 

 

[제출 결과]