結果
問題 | No.227 簡単ポーカー |
ユーザー | rf141 |
提出日時 | 2015-06-28 22:44:11 |
言語 | Java21 (openjdk 21) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,774 bytes |
コンパイル時間 | 3,816 ms |
コンパイル使用メモリ | 74,836 KB |
実行使用メモリ | 55,856 KB |
最終ジャッジ日時 | 2023-09-22 04:08:10 |
合計ジャッジ時間 | 6,719 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | AC | 132 ms
55,560 KB |
testcase_02 | AC | 132 ms
55,744 KB |
testcase_03 | AC | 129 ms
55,424 KB |
testcase_04 | AC | 129 ms
55,564 KB |
testcase_05 | AC | 130 ms
55,616 KB |
testcase_06 | WA | - |
testcase_07 | AC | 130 ms
55,744 KB |
testcase_08 | WA | - |
testcase_09 | AC | 133 ms
55,812 KB |
testcase_10 | AC | 130 ms
55,856 KB |
testcase_11 | AC | 129 ms
55,704 KB |
testcase_12 | AC | 134 ms
55,428 KB |
testcase_13 | AC | 127 ms
55,416 KB |
ソースコード
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; 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; } } } if(check_full&&check_full2)return "FULL HOUSE"; if(!check_three&&check_three2)return "THREE CARD"; break; case 1: return "NO PAIR"; } return null; } }