結果

問題 No.47 ポケットを叩くとビスケットが2倍
コンテスト
ユーザー mumucoder
提出日時 2018-10-28 23:17:14
言語 C++11
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=gnu++11 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 785 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 673 ms
コンパイル使用メモリ 79,412 KB
最終ジャッジ日時 2026-05-13 15:31:31
合計ジャッジ時間 1,449 ms
ジャッジサーバーID
(参考情報)
judge3_1 / judge1_1
このコードへのチャレンジ
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。

コンパイルメッセージ
main.cpp: In function 'int main(int, char**)':
main.cpp:11:9: error: 'uint32_t' was not declared in this scope
   11 |         uint32_t result = 0;
      |         ^~~~~~~~
main.cpp:6:1: note: 'uint32_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
    5 | #include <cmath>
  +++ |+#include <cstdint>
    6 | 
main.cpp:13:17: error: 'uint64_t' was not declared in this scope
   13 |                 uint64_t powered_num = std::pow(2, clap_num);
      |                 ^~~~~~~~
main.cpp:13:17: note: 'uint64_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
main.cpp:14:34: error: 'powered_num' was not declared in this scope
   14 |                 if (bisket_num > powered_num) {
      |                                  ^~~~~~~~~~~
main.cpp:17:35: error: 'powered_num' was not declared in this scope
   17 |                 if (bisket_num == powered_num) {
      |                                   ^~~~~~~~~~~
main.cpp:18:25: error: 'result' was not declared in this scope
   18 |                         result = clap_num;
      |                         ^~~~~~
main.cpp:21:34: error: 'powered_num' was not declared in this scope
   21 |                 if (bisket_num < powered_num) {
      |                                  ^~~~~~~~~~~
main.cpp:28:25: error: 'result' was not declared in this scope
   28 |                         result = (clap_num - 1) + 1;
      |                         ^~~~~~
main.cpp:33:22: error: 'result' was not declared in this scope
   33 |         std::cout << result << std::endl;
      |                      ^~~~~~

ソースコード

diff #
raw source code

#include <iostream>
#include <map>
#include <string>
#include <vector>
#include <cmath>

int main(int argc, char *argv[]) {
	int bisket_num = 0;
	std::cin >> bisket_num;

	uint32_t result = 0;
	for (int clap_num = 0; clap_num <= 32; clap_num++) {
		uint64_t powered_num = std::pow(2, clap_num);
		if (bisket_num > powered_num) {
			continue;
		}
		if (bisket_num == powered_num) {
			result = clap_num;
			break;
		}
		if (bisket_num < powered_num) {
			// clap_num--;
			// int base_num = std:pow(2, clap_num);
			// int sub = bisket_num - base_num;
			//
			// 結局、最後の1回は、これまで作ってきた枚数
			// より必ず小さいので、必ず1回で作れる
			result = (clap_num - 1) + 1;
			break;		
		}
	}

	std::cout << result << std::endl;

	return 0;
}
0