結果

問題 No.305 鍵(2)
ユーザー kenji_shioyakenji_shioya
提出日時 2016-06-02 05:29:57
言語 Java21
(openjdk 21)
結果
AC  
実行時間 109 ms / 2,000 ms
コード長 1,482 bytes
コンパイル時間 3,541 ms
コンパイル使用メモリ 74,988 KB
実行使用メモリ 68,340 KB
平均クエリ数 86.23
最終ジャッジ日時 2023-09-24 00:04:33
合計ジャッジ時間 5,660 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 83 ms
65,928 KB
testcase_01 AC 99 ms
66,612 KB
testcase_02 AC 81 ms
65,876 KB
testcase_03 AC 90 ms
66,652 KB
testcase_04 AC 96 ms
67,132 KB
testcase_05 AC 109 ms
66,980 KB
testcase_06 AC 68 ms
65,280 KB
testcase_07 AC 97 ms
66,760 KB
testcase_08 AC 100 ms
68,340 KB
testcase_09 AC 95 ms
66,936 KB
testcase_10 AC 92 ms
66,096 KB
testcase_11 AC 95 ms
66,832 KB
testcase_12 AC 96 ms
65,208 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++){
        System.out.println(nums);
        System.out.flush();
        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];
        }

        System.out.println(newNums);
        System.out.flush();

        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;
  }
}
0