본문 바로가기
Baekjoon Online Judge

[BOJ] 백준 2480번 주사위 세개 (Java)

by 프로그래 밍구 2023. 1. 2.

문제링크

https://www.acmicpc.net/problem/2480

 

2480번: 주사위 세개

1에서부터 6까지의 눈을 가진 3개의 주사위를 던져서 다음과 같은 규칙에 따라 상금을 받는 게임이 있다.  같은 눈이 3개가 나오면 10,000원+(같은 눈)×1,000원의 상금을 받게 된다.  같은 눈이 2개

www.acmicpc.net


나의코드

import java.util.Scanner;
import java.lang.Math;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        sc.close();
        
        int money;
        int max = Math.max(c, Math.max(a, b));
        
        
        if((a == b) && (a == c)){
            money = 10000 + a * 1000;
        }else if((a == b) && (c != a)){
            money = 1000 + a * 100;
        }else if((b == c) && (a != b)){
            money = 1000 + b * 100;
        }else if((c == a) && (b != a)){
            money = 1000 + c * 100;
        }else{
            money = max * 100;
        }
        System.out.print(money);
    }
}

 

댓글