結果

問題 No.227 簡単ポーカー
ユーザー yagi2yagi2
提出日時 2017-04-21 11:43:31
言語 Java21
(openjdk 21)
結果
AC  
実行時間 121 ms / 5,000 ms
コード長 1,293 bytes
コンパイル時間 2,062 ms
コンパイル使用メモリ 75,064 KB
実行使用メモリ 55,996 KB
最終ジャッジ日時 2023-09-27 10:51:18
合計ジャッジ時間 4,555 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 118 ms
55,696 KB
testcase_01 AC 118 ms
55,792 KB
testcase_02 AC 121 ms
55,600 KB
testcase_03 AC 120 ms
55,952 KB
testcase_04 AC 121 ms
55,980 KB
testcase_05 AC 116 ms
55,584 KB
testcase_06 AC 119 ms
55,748 KB
testcase_07 AC 117 ms
55,612 KB
testcase_08 AC 121 ms
55,776 KB
testcase_09 AC 120 ms
55,996 KB
testcase_10 AC 115 ms
54,140 KB
testcase_11 AC 121 ms
55,436 KB
testcase_12 AC 117 ms
55,472 KB
testcase_13 AC 114 ms
55,392 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        Map<Integer, Integer> cards = new HashMap<>();

        for (int i = 0; i < 5; i++) {
            int N = Integer.parseInt(sc.next());
            if (!cards.containsKey(N)) cards.put(N, 0);
            cards.put(N, cards.get(N)+1);
        }

        if (isFullHouse(cards)) {
            System.out.println("FULL HOUSE");
        } else if (isThreeCard(cards)) {
            System.out.println("THREE CARD");
        } else if (isTwoPair(cards)) {
            System.out.println("TWO PAIR");
        } else if (isOnePair(cards)) {
            System.out.println("ONE PAIR");
        } else {
            System.out.println("NO HAND");
        }
    }

    private static boolean isFullHouse(Map<Integer, Integer> cards) {
        return cards.size() == 2 && cards.containsValue(3);
    }

    private static boolean isThreeCard(Map<Integer, Integer> cards) {
        return cards.containsValue(3);
    }

    private static boolean isTwoPair(Map<Integer, Integer> cards) {
        return cards.size() == 3 && !cards.containsValue(3);
    }

    private static boolean isOnePair(Map<Integer, Integer> cards) {
        return cards.size() == 4;
    }
}
0