結果
| 問題 |
No.253 ロウソクの長さ
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-03-22 17:06:22 |
| 言語 | Java (openjdk 23) |
| 結果 |
TLE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 934 bytes |
| コンパイル時間 | 2,760 ms |
| コンパイル使用メモリ | 79,436 KB |
| 実行使用メモリ | 31,904 KB |
| 最終ジャッジ日時 | 2024-07-16 23:07:08 |
| 合計ジャッジ時間 | 9,192 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | TLE * 1 -- * 35 |
ソースコード
package yukicoder253;
import java.util.Scanner;
public class Main {
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
System.out.println("?100 ");
int a=sc.nextInt();
int count=0;
if(a==-1){
for(int i=0;i<100;i++){
System.out.println("?0");
count++;
int b=sc.nextInt();
if(b==0){
System.out.println("!"+count);
sc.close();
System.exit(0);
}
}
}else{
if(a==1){
int upper=(int)Math.pow(10,9);
int low=100;
int mid=(int)(upper+low)/2;
while(low!=upper){
count++;
System.out.println("?"+mid);
int r=sc.nextInt();
if(r==1){
mid=(upper+mid)/2;
}else if(r==-1){
mid=(low+mid)/2;
}else if(r==1){
System.out.println("!"+(mid+count));
sc.close();
System.exit(0);
}
}
}else if(a==0){
System.out.println("!100");
sc.close();
System.exit(0);
}
}
}
}