結果
問題 |
No.253 ロウソクの長さ
|
ユーザー |
|
提出日時 | 2016-03-22 17:36:13 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 222 ms / 2,000 ms |
コード長 | 1,184 bytes |
コンパイル時間 | 2,505 ms |
コンパイル使用メモリ | 80,140 KB |
実行使用メモリ | 72,224 KB |
平均クエリ数 | 34.19 |
最終ジャッジ日時 | 2024-07-16 23:07:47 |
合計ジャッジ時間 | 12,386 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 36 |
ソースコード
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(1000000000); 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=1000000000; 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){ if(upper==low+1){ System.out.println("!"+(upper+count)); sc.close(); System.exit(0); } 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); } } }