JIN.PROC // v3.1
~/ / 코딩테스트 / 2022-04-04-24568

[파이썬][백준 24568번] Cupcake Party

백준 24568번 Cupcake Party 문제 풀이

DATE 2022.04.04 UPDATED 2022.04.04 READ ~ 1 MIN WORDS 164

1. 문제

[Bronze V] Cupcake Party - 24568

문제 링크

성능 요약

메모리: 30864 KB, 시간: 72 ms

분류

사칙연산(arithmetic), 수학(math)

문제 설명

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.

입력

The input consists of two lines.

  • The first line contains an integer R ≥ 0, representing the number of regular boxes.
  • The second line contains an integer S ≥ 0, representing the number of small boxes.

출력

Output the number of cupcakes that are left over.

출처: 백준, https://https://www.acmicpc.net/

2. 해결방법 시간복잡도

  1. 단순 코딩 O(1)

3. 문제 해결 및 코드


  • 주석을 참고하면서 이해를 돕습니다.

4. 알고리즘 및 해설

  1. 문제에서 제시한 8개의 컵 케이크와 3개의 컵 케이크를 28명에게 나눠주는 것을 계산해준다.
    • 두 사이즈의 박스를 각각의 조건에 맞게 곱해준 뒤 28을 빼준 값을 출력해준다.