結果

問題 No.227 簡単ポーカー
コンテスト
ユーザー きつねうどん
提出日時 2023-11-24 21:36:28
言語 Java
(openjdk 26.0.2.1 + ac-library)
コンパイル:
javac -encoding UTF8 -cp /opt/aclib/ac_library.jar _filename_
実行:
java -ea -Xmx700m -Xss256M -DONLINE_JUDGE=true -cp .:/opt/aclib/ac_library.jar _class_
結果
AC  
実行時間 64 ms / 5,000 ms
+ 820µs
コード長 1,529 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,037 ms
コンパイル使用メモリ 89,240 KB
実行使用メモリ 43,392 KB
最終ジャッジ日時 2026-09-04 17:56:55
合計ジャッジ時間 4,593 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 14
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int c = scanner.nextInt();
        int d = scanner.nextInt();
        int e = scanner.nextInt();

        int[] list = {a, b, c, d, e};
        Arrays.sort(list);
//        System.out.println(Arrays.toString(list));

        List<Integer> countList = new ArrayList<Integer>();
        int prev = 0;
        int count = 1;
        for (int i = 0; i < 5; i++) {
            if (i != 0) {
                if (prev == list[i]) {
                    count++;
                } else {
                    countList.add(count);
                    count = 1;
                }
            }
            prev = list[i];
        }

        countList.add(count);

//        System.out.println(countList);

        if (countList.contains(3)) {
            if (countList.contains(2)) {
                System.out.println("FULL HOUSE");
            } else {
                System.out.println("THREE CARD");

            }
        } else {
            if (countList.contains(2)) {
                int twoNum = Collections.frequency(countList, 2);
                if (twoNum == 2) {
                    System.out.println("TWO PAIR");
                } else {
                    System.out.println("ONE PAIR");
                }
            } else {
                System.out.println("NO HAND");
            }
        }
    }
}
0