結果

問題 No.227 簡単ポーカー
ユーザー kenji_shioyakenji_shioya
提出日時 2016-06-09 09:12:29
言語 Java21
(openjdk 21)
結果
AC  
実行時間 136 ms / 5,000 ms
コード長 1,032 bytes
コンパイル時間 3,730 ms
コンパイル使用メモリ 78,144 KB
実行使用メモリ 41,892 KB
最終ジャッジ日時 2024-04-17 12:11:09
合計ジャッジ時間 6,142 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 122 ms
40,100 KB
testcase_01 AC 133 ms
41,684 KB
testcase_02 AC 131 ms
41,164 KB
testcase_03 AC 133 ms
41,040 KB
testcase_04 AC 123 ms
40,012 KB
testcase_05 AC 132 ms
41,240 KB
testcase_06 AC 133 ms
41,616 KB
testcase_07 AC 132 ms
41,892 KB
testcase_08 AC 132 ms
41,448 KB
testcase_09 AC 130 ms
41,344 KB
testcase_10 AC 136 ms
41,448 KB
testcase_11 AC 133 ms
41,736 KB
testcase_12 AC 133 ms
41,500 KB
testcase_13 AC 120 ms
40,156 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Exercise71{
  public static void main (String[] args){

    Scanner sc = new Scanner(System.in);

    int[] cards = new int[5];
    int[] pairs = new int[5];

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

    for(int i = 0; i < 5; i++){
      int count = 0;
      for(int j = 0; j < 5; j++){
        if(cards[i] == cards[j]){
          count++;
        }
      }
      pairs[i] = count;
    }

    Arrays.sort(pairs);

    int[] fullhouse = new int[]{2, 2, 3, 3, 3};
    int[] threecard = {1, 1, 3, 3, 3};
    int[] twopair = {1, 2, 2, 2, 2};
    int[] onepair = {1, 1, 1, 2, 2};

    if(Arrays.equals(pairs, fullhouse)){
      System.out.println("FULL HOUSE");
    }else if(Arrays.equals(pairs, threecard)){
      System.out.println("THREE CARD");
    }else if(Arrays.equals(pairs, twopair)){
      System.out.println("TWO PAIR");
    }else if(Arrays.equals(pairs, onepair)){
      System.out.println("ONE PAIR");
    }else{
      System.out.println("NO HAND");
    }
  }
}
0