최대 1 분 소요

1. 문제Permalink

[Bronze V] Cupcake Party - 24568Permalink

문제 링크

성능 요약Permalink

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

분류Permalink

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

문제 설명Permalink

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.

입력Permalink

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.

출력Permalink

Output the number of cupcakes that are left over.

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

2. 해결방법 시간복잡도Permalink

  1. 단순 코딩 O(1)

3. 문제 해결 및 코드Permalink


A = int(input())
B = int(input())
print((A * 8) + (B * 3) - 28)
view raw 24568.py hosted with ❤ by GitHub
  • 주석을 참고하면서 이해를 돕습니다.Permalink

4. 알고리즘 및 해설Permalink

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