Problem
You record all of the scoring activity at a basketball game. Points are scored by a 3-point shot, a 2-point field goal, or a 1-point free throw.
You know the number of each of these types of scoring for the two teams: the Apples and the Bananas. Your job is to determine which team won, or if the game ended in a tie.
Input
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
Output
The output will be a single character. If the Apples scored more points than the Bananas, output 'A'. If the Bananas scored more points than the Apples, output 'B'. Otherwise, output 'T', to indicate a tie.
Solution
기본문제.ㅇㅅㅇ
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
import java.text.SimpleDateFormat;
class Bakjoon {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int sum=0;
int cnt=3;
int sum1=0;
for(int i=1;i<7;i++) {
int a=sc.nextInt();
sum+= a*cnt;
cnt--;
if(i==3) {
sum1=sum;
cnt=3;
sum=0;
}
}
if(sum1==sum) {
System.out.println("T");
}
else {
System.out.println(sum1>sum?"A":"B");
}
}
}
|
https://www.acmicpc.net/problem/17009
'Algorithms > BOJ[Java]' 카테고리의 다른 글
[백준/5612번] 터널의 입구와 출구(JOI 2006 모의고사 2)[Java] (0) | 2019.12.10 |
---|---|
[백준/5585번] 거스름돈 (JOI 2008 예선)[Java] (0) | 2019.12.10 |
[백준/13597번] Tri-du( A Primeira Fase da Maratona de Programação 2015) [Java] (0) | 2019.12.09 |
[백준/11319번] Count Me In (CCPC 2015 Division 2) [Java] (0) | 2019.12.09 |
[백준/11104번] Fridge of Your Dreams ( IDI Open 2007 )[Java] (0) | 2019.12.09 |