結果

問題 No.305 鍵(2)
ユーザー kenji_shioyakenji_shioya
提出日時 2016-06-02 05:20:08
言語 Java21
(openjdk 21)
結果
RE  
実行時間 -
コード長 1,440 bytes
コンパイル時間 3,465 ms
コンパイル使用メモリ 75,116 KB
実行使用メモリ 67,216 KB
平均クエリ数 79.62
最終ジャッジ日時 2023-09-23 10:46:00
合計ジャッジ時間 6,491 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 AC 101 ms
66,796 KB
testcase_02 RE -
testcase_03 AC 95 ms
66,636 KB
testcase_04 AC 105 ms
67,020 KB
testcase_05 AC 118 ms
66,260 KB
testcase_06 AC 68 ms
64,868 KB
testcase_07 WA -
testcase_08 AC 106 ms
66,376 KB
testcase_09 AC 99 ms
66,648 KB
testcase_10 AC 100 ms
66,900 KB
testcase_11 AC 101 ms
66,560 KB
testcase_12 AC 106 ms
67,216 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);

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

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

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

        if (resultAfterNum == 10){
          break a;
        }else if (resultAfterNum > resultBeforeNum){
          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