728x90
반응형
백준알고리즘
- Bronze 5 -
#24568. Cupcake Party by JAVA and node.js
문제
출처: https://www.acmicpc.net/problem/24568
번역: https://www.acmicpc.net/board/view/85461
글 읽기 - (번역) 24568 - 컵케이크 파티
댓글을 작성하려면 로그인해야 합니다.
www.acmicpc.net
접근 방법
간단한 방정식 문제이다.
첫 줄에 일반 케이크박스의 수 R이 주어지고, 두 번째 줄에 작은 케이크박스의 수 S가 주어진다.
그러면 전체 케이크의 수는 8*R + 3*S 가 되고, 학생 수는 28이므로 남는 케이크의 수는 8*R + 3*S - 28이 된다.
풀이
▶ JAVA
import java.util.*;
public class Main {
public static void main(String[] args){
Scanner scan = new Scanner(System.in);
int r = scan.nextInt();
int s = scan.nextInt();
scan.close();
System.out.println(8 * r + 3 * s - 28);
}
}
▶ node.js
var fs = require('fs');
var input = fs.readFileSync('/dev/stdin').toString().trim().split('\n');
var r = input[0];
var s = input[1];
console.log(8 * r + 3 * s - 28);
결과
End.
heisely's 괴발개발 개발일지
728x90
반응형
'알고리즘 > 백준알고리즘' 카테고리의 다른 글
[백준알고리즘] #1297. TV 크기 (by JAVA and node.js) (0) | 2022.04.19 |
---|---|
[백준알고리즘] #24736. Football Scoring (by JAVA and node.js) (0) | 2022.04.18 |
[백준알고리즘] #24262. 알고리즘 수업 - 알고리즘의 수행 시간 1 (by JAVA and node.js) (0) | 2022.04.14 |
[백준알고리즘] #24218. Double Crypt 1 (by JAVA and node.js) (0) | 2022.04.14 |
[백준알고리즘] #24183. Affischutskicket (by JAVA and node.js) (0) | 2022.04.14 |