結果
問題 |
No.227 簡単ポーカー
|
ユーザー |
|
提出日時 | 2017-04-21 11:43:31 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 122 ms / 5,000 ms |
コード長 | 1,293 bytes |
コンパイル時間 | 2,357 ms |
コンパイル使用メモリ | 79,788 KB |
実行使用メモリ | 41,256 KB |
最終ジャッジ日時 | 2024-07-20 05:01:04 |
合計ジャッジ時間 | 4,299 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 14 |
ソースコード
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); Map<Integer, Integer> cards = new HashMap<>(); for (int i = 0; i < 5; i++) { int N = Integer.parseInt(sc.next()); if (!cards.containsKey(N)) cards.put(N, 0); cards.put(N, cards.get(N)+1); } if (isFullHouse(cards)) { System.out.println("FULL HOUSE"); } else if (isThreeCard(cards)) { System.out.println("THREE CARD"); } else if (isTwoPair(cards)) { System.out.println("TWO PAIR"); } else if (isOnePair(cards)) { System.out.println("ONE PAIR"); } else { System.out.println("NO HAND"); } } private static boolean isFullHouse(Map<Integer, Integer> cards) { return cards.size() == 2 && cards.containsValue(3); } private static boolean isThreeCard(Map<Integer, Integer> cards) { return cards.containsValue(3); } private static boolean isTwoPair(Map<Integer, Integer> cards) { return cards.size() == 3 && !cards.containsValue(3); } private static boolean isOnePair(Map<Integer, Integer> cards) { return cards.size() == 4; } }