結果

問題 No.246 質問と回答
ユーザー akakimidori
提出日時 2015-07-17 23:12:32
言語 C90
(gcc 12.3.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 443 bytes
コンパイル時間 150 ms
コンパイル使用メモリ 20,864 KB
実行使用メモリ 42,656 KB
最終ジャッジ日時 2024-07-16 19:44:38
合計ジャッジ時間 6,532 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other TLE * 1 -- * 29
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:30:9: warning: format ‘%d’ expects argument of type ‘int *’, but argument 2 has type ‘int’ [-Wformat=]
   30 | scanf("%d",ans);
      |        ~^  ~~~
      |         |  |
      |         |  int
      |         int *
main.c:15:2: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   15 |  scanf("%d",&ans);
      |  ^~~~~~~~~~~~~~~~
main.c:30:1: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   30 | scanf("%d",ans);
      | ^~~~~~~~~~~~~~~

ソースコード

diff #

#include<stdio.h>

typedef long long int ln;

int main(void){

ln low=1;
ln high=1000000000;

while(low+1<high){
 ln m=(low+high)/2;
 printf("? %lld\n",m);
fflush(stdin);
 int ans;
 scanf("%d",&ans);
 if(ans){
  low=m;
 } else {
  high=m;
 }
}
if(high==low){
printf("! %lld\n",low);
return 0;
}
printf("? %lld\n",high);
fflush(stdin);

int ans;
scanf("%d",ans);
if(ans){
printf("! %lld\n",high);
} else {
printf("! %lld\n",low);
}
return 0;
}
0