結果

問題 No.227 簡単ポーカー
ユーザー kenji_shioya
提出日時 2016-06-09 09:12:29
言語 Java
(openjdk 23)
結果
AC  
実行時間 135 ms / 5,000 ms
コード長 1,032 bytes
コンパイル時間 3,653 ms
コンパイル使用メモリ 77,816 KB
実行使用メモリ 41,860 KB
最終ジャッジ日時 2024-10-09 06:12:55
合計ジャッジ時間 6,506 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 14
権限があれば一括ダウンロードができます

ソースコード

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