結果

問題 No.355 数当てゲーム(2)
ユーザー ぴろずぴろず
提出日時 2016-04-01 23:49:45
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,004 bytes
コンパイル時間 5,883 ms
コンパイル使用メモリ 79,180 KB
実行使用メモリ 74,424 KB
平均クエリ数 16.96
最終ジャッジ日時 2023-09-23 09:51:16
合計ジャッジ時間 21,326 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 153 ms
71,792 KB
testcase_01 AC 154 ms
71,780 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 155 ms
72,128 KB
testcase_08 WA -
testcase_09 AC 155 ms
71,984 KB
testcase_10 WA -
testcase_11 AC 155 ms
72,184 KB
testcase_12 AC 153 ms
72,388 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 153 ms
72,300 KB
testcase_18 AC 150 ms
71,512 KB
testcase_19 WA -
testcase_20 AC 159 ms
74,424 KB
testcase_21 AC 166 ms
72,336 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 161 ms
71,888 KB
testcase_25 AC 156 ms
71,772 KB
testcase_26 WA -
testcase_27 AC 158 ms
71,436 KB
testcase_28 AC 167 ms
72,396 KB
testcase_29 AC 157 ms
74,052 KB
testcase_30 WA -
testcase_31 AC 150 ms
72,388 KB
testcase_32 AC 160 ms
71,536 KB
testcase_33 WA -
testcase_34 AC 150 ms
72,140 KB
testcase_35 AC 148 ms
72,148 KB
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 AC 162 ms
71,728 KB
testcase_41 AC 160 ms
72,008 KB
testcase_42 AC 153 ms
72,196 KB
testcase_43 AC 174 ms
71,860 KB
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
testcase_47 WA -
testcase_48 WA -
testcase_49 AC 161 ms
71,924 KB
testcase_50 WA -
testcase_51 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

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();
	}

}
0