結果

問題 No.227 簡単ポーカー
ユーザー ほげ太郎ほげ太郎
提出日時 2018-02-26 10:16:03
言語 Java21
(openjdk 21)
結果
AC  
実行時間 128 ms / 5,000 ms
コード長 1,268 bytes
コンパイル時間 2,045 ms
コンパイル使用メモリ 78,152 KB
実行使用メモリ 56,180 KB
最終ジャッジ日時 2023-08-14 09:40:19
合計ジャッジ時間 4,841 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 124 ms
55,604 KB
testcase_01 AC 125 ms
55,780 KB
testcase_02 AC 124 ms
55,972 KB
testcase_03 AC 123 ms
56,180 KB
testcase_04 AC 122 ms
55,780 KB
testcase_05 AC 123 ms
55,720 KB
testcase_06 AC 124 ms
55,860 KB
testcase_07 AC 122 ms
56,040 KB
testcase_08 AC 123 ms
55,740 KB
testcase_09 AC 123 ms
55,728 KB
testcase_10 AC 125 ms
55,972 KB
testcase_11 AC 128 ms
56,008 KB
testcase_12 AC 126 ms
55,492 KB
testcase_13 AC 125 ms
55,968 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 && !four) {
            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