結果

問題 No.305 鍵(2)
ユーザー YamaKasaYamaKasa
提出日時 2018-09-10 22:17:32
言語 Java21
(openjdk 21)
結果
AC  
実行時間 168 ms / 2,000 ms
コード長 803 bytes
コンパイル時間 2,242 ms
コンパイル使用メモリ 71,528 KB
実行使用メモリ 72,240 KB
平均クエリ数 44.08
最終ジャッジ日時 2023-09-24 01:53:51
合計ジャッジ時間 5,317 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 134 ms
71,412 KB
testcase_01 AC 152 ms
71,968 KB
testcase_02 AC 143 ms
71,804 KB
testcase_03 AC 159 ms
71,892 KB
testcase_04 AC 160 ms
72,240 KB
testcase_05 AC 168 ms
71,492 KB
testcase_06 AC 141 ms
71,760 KB
testcase_07 AC 152 ms
71,884 KB
testcase_08 AC 156 ms
71,548 KB
testcase_09 AC 152 ms
69,364 KB
testcase_10 AC 159 ms
71,420 KB
testcase_11 AC 149 ms
71,796 KB
testcase_12 AC 158 ms
72,136 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		StringBuilder key = new StringBuilder("0000000000");
		System.out.println(key.toString());
		int X = scan.nextInt();
		String t = scan.next();
		if(t.equals("unlocked")) {
			System.exit(0);
		}
		for(int i = 0; i < 10; i++) {
			String s0 = key.toString();
			for(int j = 1; j < 10; j++) {
				String s = key.replace(i, i + 1, Integer.toString(j)).toString();
				System.out.println(s);
				int k = scan.nextInt();
				t = scan.next();
				if(t.equals("unlocked")) {
					System.exit(0);
				}
				if(k > X) {
					key = new StringBuilder(s);
					X = k;
					break;
				}else if(k < X) {
					key = new StringBuilder(s0);
					break;
				}
			}
		}
		scan.close();
	}
}
0