Solved.ac - Python/Bronze V
[파이썬/Python] 백준 24568번 Cupcake Party
ImJay
2022. 12. 1. 17:39
반응형
[파이썬/Python] 백준 24568번 Cupcake Party
24568번: Cupcake Party
A regular box of cupcakes holds 8 cupcakes, while a small box holds 3 cupcakes. There are 28 students in a class and a total of at least 28 cupcakes. Your job is to determine how many cupcakes will be left over if each student gets one cupcake.
www.acmicpc.net
문제
A regular box of cupcakes holds 8 cupcakes, while a small box holds 3 cupcakes. There are 28 students in a class and a total of at least 28 cupcakes. Your job is to determine how many cupcakes will be left over if each student gets one cupcake.
해설
8개의 컵케이크가 들어있는 박스의 갯수 : R
3개의 컵케이크가 들어있는 박스의 갯수 : S
28명이 각 1개의 케이크를 먹을 때, 남는 컵케이크의 개수를 구해보자
left_over = R * 8 + S * 3 - 28
총 컵케이크의 갯수를 구해 28명이 먹을 컵케이크 수인 28을 빼면 남는 컵케이크의 수가 된다.
코드
R = int(input())
S = int(input())
print(R*8 + S*3 - 28)
풀이
1. 컵케이크 박스 R, S의 개수를 입력 받는다.
R = int(input())
S = int(input())
2. 남는 컵케이크 수를 출력한다.
print(R*8 + S*3 - 28)

반응형