結果

問題 No.47 ポケットを叩くとビスケットが2倍
ユーザー kapo
提出日時 2016-04-14 18:22:07
言語 C90
(gcc 12.3.0)
結果
WA  
実行時間 -
コード長 362 bytes
コンパイル時間 266 ms
コンパイル使用メモリ 20,608 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-10-04 08:43:31
合計ジャッジ時間 1,039 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 14 WA * 7
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:6:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    6 |         scanf("%d", &n);
      |         ^~~~~~~~~~~~~~~

ソースコード

diff #

#include <stdio.h>

int main(void)
{
	int n, i = 0, biscuit = 1;
	scanf("%d", &n);

	while (n >= biscuit*2) {
		biscuit = biscuit * 2;
		i++;
	}

	if (n == biscuit) {
		printf("%d\n", i);
		return 0;
	} else if (n == biscuit+1) {
		printf("%d\n", i+1);
		return 0;
	}

	if ((n - biscuit)%2 == 0) {
		i += 1;
	} else { i += 2;
	}

	printf("%d\n", i);
	return 0;
}
0