結果

問題 No.47 ポケットを叩くとビスケットが2倍
ユーザー kantarow_
提出日時 2017-12-06 23:14:03
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 1 ms / 5,000 ms
コード長 242 bytes
コンパイル時間 136 ms
コンパイル使用メモリ 22,400 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-11-29 01:31:17
合計ジャッジ時間 1,000 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:5:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    5 |   scanf("%d", &n);
      |   ~~~~~^~~~~~~~~~

ソースコード

diff #

#include<stdio.h>

int main(){
  int n;
  scanf("%d", &n);

  int i = 0, fact = 1;

  while(n >= fact * 2){
    fact *= 2;
    i++;
  }
  if(n == fact){
    printf("%d\n", i);
  }else{
    printf("%d\n", i + 1);
  }

  
}
0