結果
| 問題 |
No.227 簡単ポーカー
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-11-24 21:36:28 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 129 ms / 5,000 ms |
| コード長 | 1,529 bytes |
| コンパイル時間 | 2,573 ms |
| コンパイル使用メモリ | 78,736 KB |
| 実行使用メモリ | 41,492 KB |
| 最終ジャッジ日時 | 2024-09-26 08:59:21 |
| 合計ジャッジ時間 | 5,092 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 14 |
ソースコード
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int a = scanner.nextInt();
int b = scanner.nextInt();
int c = scanner.nextInt();
int d = scanner.nextInt();
int e = scanner.nextInt();
int[] list = {a, b, c, d, e};
Arrays.sort(list);
// System.out.println(Arrays.toString(list));
List<Integer> countList = new ArrayList<Integer>();
int prev = 0;
int count = 1;
for (int i = 0; i < 5; i++) {
if (i != 0) {
if (prev == list[i]) {
count++;
} else {
countList.add(count);
count = 1;
}
}
prev = list[i];
}
countList.add(count);
// System.out.println(countList);
if (countList.contains(3)) {
if (countList.contains(2)) {
System.out.println("FULL HOUSE");
} else {
System.out.println("THREE CARD");
}
} else {
if (countList.contains(2)) {
int twoNum = Collections.frequency(countList, 2);
if (twoNum == 2) {
System.out.println("TWO PAIR");
} else {
System.out.println("ONE PAIR");
}
} else {
System.out.println("NO HAND");
}
}
}
}