結果
| 問題 | No.253 ロウソクの長さ | 
| コンテスト | |
| ユーザー |  jj | 
| 提出日時 | 2016-08-26 22:03:16 | 
| 言語 | Fortran (gFortran 14.2.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 27 ms / 2,000 ms | 
| コード長 | 944 bytes | 
| コンパイル時間 | 1,650 ms | 
| コンパイル使用メモリ | 31,360 KB | 
| 実行使用メモリ | 25,476 KB | 
| 平均クエリ数 | 35.14 | 
| 最終ジャッジ日時 | 2024-07-17 00:21:23 | 
| 合計ジャッジ時間 | 4,700 ms | 
| ジャッジサーバーID (参考情報) | judge5 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 36 | 
ソースコード
program main
  implicit none
  integer,parameter::limit=100
  integer::upper=10**9+1,lower,mid
  integer::i,ans,query
  integer,parameter::short=-1,long=1,same=0
  integer*8::N
  query = 99
  call ask(query)
  read *,ans
  if(ans.eq.same) then
     print '("!",i0)',query
     return
  else if(ans.eq.short) then
     query = 0
     do i=1,limit-1
        call ask(query)
        read *,ans
        if(ans.eq.same) then
           print '("!",i0)',i
           return
        end if
     end do
     print '("!",i0)',query
  end if
  lower = 100
  do i=1,limit-1
     mid = (lower+upper)/2
     query = mid-i
     call ask(query)
     read *,ans
     if(ans.eq.same) then
        print '("!",i0)',i+query
        return
     else if(ans.eq.short) then
        upper = mid
     else
        lower = mid
     end if
  end do
contains
  subroutine ask(query)
    integer::query
    print '("?",i0)',query
  end subroutine ask
end program main
            
            
            
        