結果

問題 No.227 簡単ポーカー
ユーザー ほげ太郎ほげ太郎
提出日時 2018-02-26 10:12:16
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,259 bytes
コンパイル時間 2,189 ms
コンパイル使用メモリ 77,204 KB
実行使用メモリ 52,816 KB
最終ジャッジ日時 2024-05-01 21:59:35
合計ジャッジ時間 5,207 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 120 ms
41,108 KB
testcase_02 AC 116 ms
41,160 KB
testcase_03 AC 115 ms
41,272 KB
testcase_04 AC 107 ms
41,412 KB
testcase_05 AC 118 ms
41,396 KB
testcase_06 AC 115 ms
41,244 KB
testcase_07 AC 116 ms
41,132 KB
testcase_08 AC 115 ms
41,156 KB
testcase_09 AC 120 ms
41,076 KB
testcase_10 AC 119 ms
39,944 KB
testcase_11 AC 120 ms
41,040 KB
testcase_12 AC 122 ms
41,188 KB
testcase_13 AC 116 ms
40,948 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

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

        int[] a = new int[5];

        for (int i = 0; i < 5; i++)
            a[i] = sc.nextInt();

        for (int i = 0; i < a.length; i++) {
            for (int j = i + 1; j < a.length; j++) {
                if (a[i] > a[j]) {
                    int tmp = a[i];
                    a[i] = a[j];
                    a[j] = tmp;
                }
            }
        }

        int match = 0;
        boolean three = false;
        boolean four = false;

        for (int i = 0; i < a.length - 1; i++) {
            if (a[i] == a[i + 1]) {
                match += 1;
                three |= (i + 2 < a.length) && (a[i] == a[i + 2]);
                four |= (i + 3 < a.length) && (a[i] == a[i + 3]);
            }
        }

        if (match == 3) {
            System.out.println("FULL HOUSE");
        } else if (three && !four) {
            System.out.println("THREE CARD");
        } else if (match == 2) {
            System.out.println("TWO PAIR");
        } else if (match == 1) {
            System.out.println("ONE PAIR");
        } else {
            System.out.println("NO HAND");
        }
    }
}
0