자바 백준 16727번
브론즈 4
https://www.acmicpc.net/problem/16727
16727번: ICPC
The first line of the input contains two space-separated integers p1 and s1, where p1 and s1 are the number of goals scored by Persepolis and Esteghlal, respectively, in the first match in which Persepolis is the home team. The second line contains two spa
www.acmicpc.net
문제 보기
분류: 구현
문제 풀기
결승 경기에서 홈 어웨이 방식으로 두 게임을 진행하고 총득점이 많은 팀이 승리를 한다. 이때, 총득점이 같을 때에는 원정 다득점 규칙을 적용하여 원정 경기에서 많은 득점을 넣은 팀이 승리를 한다. 이 원정 다득점마저도 같다면 승부차기로 넘어가는 룰을 적용하고 있다.
위의 우승팀을 가리는 규칙에 따라 if, else if, else 조건문을 사용하여 출력 결과를 구분한다.
코드 보기
import java.util.Scanner;
public class Main {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
int p1 = sc.nextInt();
int s1 = sc.nextInt();
int s2 = sc.nextInt();
int p2 = sc.nextInt();
if (p1 + p2 > s1 + s2) {
System.out.print("Persepolis");
}
else if (p1 + p2 < s1 + s2) {
System.out.print("Esteghlal");
}
else if (p1 + p2 == s1 + s2) {
if (p2 > s1) {
System.out.print("Persepolis");
}
else if (p2 < s1) {
System.out.print("Esteghlal");
}
else {
System.out.print("Penalty");
}
}
}
}
'공부하기 > 백준' 카테고리의 다른 글
[Java] 백준 풀기 17350 - 2루수 이름이 뭐야 (0) | 2023.03.28 |
---|---|
[Java] 백준 풀기 26766 - Serca (0) | 2023.03.27 |
[Java] 백준 풀기 18398 - HOMWRK (0) | 2023.03.25 |
[Java] 백준 풀기 21591 - Laptop Sticker (0) | 2023.03.24 |
[Java] 백준 풀기 17094 - Serious Problem (0) | 2023.03.23 |