結果

問題 No.305 鍵(2)
ユーザー kenji_shioyakenji_shioya
提出日時 2016-06-02 05:37:46
言語 Java21
(openjdk 21)
結果
AC  
実行時間 117 ms / 2,000 ms
コード長 1,499 bytes
コンパイル時間 3,500 ms
コンパイル使用メモリ 75,344 KB
実行使用メモリ 67,172 KB
平均クエリ数 86.23
最終ジャッジ日時 2023-09-24 00:04:13
合計ジャッジ時間 5,877 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 84 ms
65,816 KB
testcase_01 AC 103 ms
66,880 KB
testcase_02 AC 86 ms
65,568 KB
testcase_03 AC 94 ms
66,436 KB
testcase_04 AC 99 ms
66,620 KB
testcase_05 AC 117 ms
67,172 KB
testcase_06 AC 67 ms
65,488 KB
testcase_07 AC 101 ms
66,728 KB
testcase_08 AC 108 ms
67,016 KB
testcase_09 AC 98 ms
64,812 KB
testcase_10 AC 97 ms
66,760 KB
testcase_11 AC 99 ms
66,536 KB
testcase_12 AC 107 ms
66,724 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
import java.io.*;

public class Exercise47{
  public static void main (String[] args) throws IOException{

    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));

    String nums = "0000000000";
    String[] numArray = nums.split("");

    a: for (int a = 0; a < 10; a++){
      b: for (int b = 0; b < 10; b++){

        print(nums);
        String result = new String(in.readLine());

        int resultBeforeNum = getAnswer(result);
        if (resultBeforeNum == 10){
          break a;
        }

        int currentNum = Integer.parseInt(numArray[a]);
        int changedNum = currentNum + 1;
        numArray[a] = String.valueOf(changedNum);

        String newNums = "";
        for (int n = 0; n < 10; n++){
          newNums += numArray[n];
        }

        print(newNums);

        result = new String(in.readLine());
        int resultAfterNum = getAnswer(result);

        if (resultAfterNum == 10){
          break a;
        }else if (resultAfterNum > resultBeforeNum){
          nums = newNums;
          break b;
        }else if (resultAfterNum < resultBeforeNum){
          numArray[a] = String.valueOf(currentNum);
          break b;
        }
      }
    }
  }
  public static int getAnswer(String result){

    String[] resultArray = result.split(" ");

    int resultNum = Integer.parseInt(resultArray[0]);
    return resultNum;
  }

  public static void print(String str){
    System.out.println(str);
    System.out.flush();
  }
}
0