치춘짱베리굿나이스

[백준] 24568 본문

Javascript + Typescript/자바스크립트로 알고리즘풀기

[백준] 24568

치춘 2022. 7. 16. 00:41

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.

입력

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.

풀이

const cupcake = () => {
  let [r, s] = require("fs")
    .readFileSync("/dev/stdin")
    .toString()
    .trim()
    .split("\n")
    .map(Number);
  console.log(r * 8 + s * 3 > 28 ? r * 8 + s * 3 - 28 : 0);
};

cupcake();

'Javascript + Typescript > 자바스크립트로 알고리즘풀기' 카테고리의 다른 글

[백준] 25372  (0) 2022.07.17
[백준] 24262  (0) 2022.07.16
[백준] 24736  (0) 2022.07.16
[백준] 25311  (0) 2022.07.14
[백준] 25314  (0) 2022.07.14
Comments