結果
| 問題 |
No.355 数当てゲーム(2)
|
| コンテスト | |
| ユーザー |
ぴろず
|
| 提出日時 | 2016-04-01 23:49:45 |
| 言語 | Java (openjdk 23) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,004 bytes |
| コンパイル時間 | 3,497 ms |
| コンパイル使用メモリ | 77,048 KB |
| 実行使用メモリ | 72,276 KB |
| 平均クエリ数 | 15.37 |
| 最終ジャッジ日時 | 2024-07-16 09:26:50 |
| 合計ジャッジ時間 | 18,068 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 19 WA * 32 RE * 1 |
ソースコード
package no355;
import java.util.Scanner;
public class Main {
static int[] query = new int[4];
static int hit = 0;
static int blow = 0;
static Scanner sc = new Scanner(System.in);
public static void main(String[] args) {
while(true) {
for(int i=0;i<4;i++) {
query[i] = (int) (Math.random() * 10);
}
if (!isValid()) continue;
query();
if (hit == 0) break;
}
for(int i=0;i<4;i++) {
for(int j=0;j<=9;j++) {
query[i] = j;
if (!isValid()) continue;
query();
if (hit == i + 1) {
break;
}
}
}
}
public static boolean isValid() {
boolean[] used = new boolean[10];
for(int i=0;i<4;i++) {
int x = query[i];
if (used[x]) {
return false;
}
used[x] = true;
}
return true;
}
public static void query() {
StringBuilder sb = new StringBuilder();
for(int i=0;i<4;i++) {
if (i > 0) sb.append(' ');
sb.append(query[i]);
}
System.out.println(sb.toString());
hit = sc.nextInt();
blow = sc.nextInt();
}
}
ぴろず