結果

問題 No.227 簡単ポーカー
ユーザー rf141rf141
提出日時 2015-06-28 22:48:27
言語 Java21
(openjdk 21)
結果
AC  
実行時間 124 ms / 5,000 ms
コード長 1,860 bytes
コンパイル時間 3,596 ms
コンパイル使用メモリ 76,636 KB
実行使用メモリ 56,068 KB
最終ジャッジ日時 2023-09-22 04:08:48
合計ジャッジ時間 6,437 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 124 ms
55,708 KB
testcase_01 AC 121 ms
55,716 KB
testcase_02 AC 119 ms
55,736 KB
testcase_03 AC 120 ms
55,700 KB
testcase_04 AC 119 ms
56,068 KB
testcase_05 AC 120 ms
55,968 KB
testcase_06 AC 119 ms
55,772 KB
testcase_07 AC 119 ms
55,676 KB
testcase_08 AC 120 ms
55,920 KB
testcase_09 AC 118 ms
55,752 KB
testcase_10 AC 118 ms
55,740 KB
testcase_11 AC 120 ms
55,656 KB
testcase_12 AC 119 ms
55,932 KB
testcase_13 AC 120 ms
55,992 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
public class EasyPorker {
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int[] card = new int[5];
		for(int i=0;i<5;i++){
			card[i]=scan.nextInt();
		}
		Map<Integer,Integer> cardNum = new HashMap<Integer,Integer>();
		int count=0;
		for(int i=0; i < 5; i++){
			if(!cardNum.containsKey(card[i])){
				cardNum.put(card[i], 1);
			}else{
				int getNum = cardNum.get(card[i]);
				getNum++;
				cardNum.put(card[i], getNum);
			}
		}
		
		System.out.println(checkHands(cardNum));
		
	}
	
	public static String checkHands(Map<Integer, Integer> cardNum){
		
		boolean check_two=false;
		boolean check_three=false;
		boolean check_full=false;
		
		boolean check_two2=false;
		boolean check_three2=false;
		boolean check_full2=false;
		
		boolean e=false;
		
		switch(cardNum.size()){
		case 5:
			return "NO HAND";
		case 4:
			return "ONE PAIR";
		case 3:
			for(int i = 1; i <= 13; i++){
				if(cardNum.containsKey(i)){
					int get = cardNum.get(i);
					if(get==2){
						check_two=true;
						check_full=true;
						check_three=false;
					}else if(get==3){
						check_three2=true;
						check_full2=true;
						check_two2=false;
					}
				}
			}
			if(check_two&&!check_two2)return "TWO PAIR";
			if(!check_three&&check_three2)return "THREE CARD";
			if(check_full&&check_full2)return "FULL HOUSE";
			break;
		case 2:
			for(int i=1;i<=13;i++){
				if(cardNum.containsKey(i)){
					int get = cardNum.get(i);
					if(get==2){
						check_full=true;
						check_three=false;
					}else if(get==3){
						check_full2=true;
						check_three2=false;
					}else if(get==4){
						e=true;
					}
				}
			}
			if(check_full&&check_full2)return "FULL HOUSE";
			if(!check_three&&check_three2)return "THREE CARD";
			if(e)return "NO HAND";
			break;
		case 1:
			return "NO HAND";
		}
		return null;
	}
}
0