본문 바로가기
Algorithm

[구현/수학] 백준 24568 Cupcake Party - 파이썬(Python)

by jangThang 2022. 7. 18.
반응형

백준 온라인 저지

 

[ Contents ]

     

     

    1. 문제 (링크 참조)

     

    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

     

     

     

    2. 문제 풀이

     작은 상자에는 3개씩, 큰 상자에는 8개씩 컵 케이크가 들어있습니다. 작은 상자와 큰 상자의 개수가 주어질 때, 28개를 제외하고 남는 컵 케이크 수를 구해야 합니다.

     

     

     

    3. 코드

    # 입력
    R = int(input())
    S = int(input())
    
    # 출력
    res = R*8 + S*3 - 28
    print(res if res >= 0 else 0)

     28개보다 많으면 남고, 적으면 남지 않습니다. (0개)

     

    star가 되고나서 Tistory

    반응형

    댓글