結果

問題 No.253 ロウソクの長さ
ユーザー 37zigen
提出日時 2016-03-22 17:25:56
言語 Java
(openjdk 23)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,055 bytes
コンパイル時間 2,565 ms
コンパイル使用メモリ 79,836 KB
実行使用メモリ 82,568 KB
平均クエリ数 32.17
最終ジャッジ日時 2024-07-16 23:08:02
合計ジャッジ時間 14,891 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 33 TLE * 1 -- * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

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");
		System.err.println(101);
		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=101;
			int mid;
			int ans=101;
			while(low!=upper){
				count++;
				upper--;
				low--;
				ans--;
				mid=(int)(upper+low)/2;
				System.out.println("?"+mid);
				System.err.println("ans="+ans);
				System.err.println("upper="+upper+" low="+low);
				int r=sc.nextInt();
				if(r==1){
					low=mid;
				}else if(r==-1){
					upper=mid;
				}else if(r==0){
					System.out.println("!"+(mid+count));
					sc.close();
					System.exit(0);
				}
			}
		}else if(a==0){
			System.out.println("!100");
			sc.close();
			System.exit(0);
		}

	}
}

0