자바 백준 17009번
브론즈 4
https://www.acmicpc.net/problem/17009
17009번: Winning Score
The first three lines of input describe the scoring of the Apples, and the next three lines of input describe the scoring of the Bananas. For each team, the first line contains the number of successful 3-point shots, the second line contains the number of
www.acmicpc.net
문제 보기

분류: 수학, 구현, 사칙연산
문제 풀기
주어진 입력에 대해 각 해당 위치의 숫자와 점수 3, 2, 1 을 1 대 1 매칭하여 곱셈 계산을 한다.
각 팀의 점수 합을 비교하여 A 또는 B 또는 C 를 출력한다.
코드 보기
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int a_3 = sc.nextInt();
int a_2 = sc.nextInt();
int a_1 = sc.nextInt();
int b_3 = sc.nextInt();
int b_2 = sc.nextInt();
int b_1 = sc.nextInt();
int total_a = (a_3 * 3) + (a_2 * 2) + (a_1 * 1);
int total_b = (b_3 * 3) + (b_2 * 2) + (b_1 * 1);
if (total_a == total_b) {
System.out.print("T");
}
else if (total_a > total_b) {
System.out.print("A");
}
else if (total_a < total_b) {
System.out.print("B");
}
}
}
'공부하기 > 백준' 카테고리의 다른 글
| [Java] 백준 풀기 10821 - 정수의 개 (0) | 2023.03.17 |
|---|---|
| [Java] 백준 풀기 15059 - hard choice (0) | 2023.03.16 |
| [Java] 백준 풀기 17863 - FYI (0) | 2023.03.13 |
| [Python] 백준 풀기 24883 - 자동완성 (1) | 2023.03.11 |
| [Python] 백준 풀기 14909 - 양수 개수 세기 (0) | 2023.03.10 |