結果

問題 No.47 ポケットを叩くとビスケットが2倍
ユーザー ふゆふみ🔞ざーめん処理用
提出日時 2015-07-13 16:02:28
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 456 bytes
コンパイル時間 374 ms
コンパイル使用メモリ 54,904 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-08 07:00:00
合計ジャッジ時間 1,092 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 3
other WA * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>

int sumTatakuT( int n )
{
	if( n < 0 ){
		n = -n;
	}

	int distance = 0;
	bool exponent2 = true;
	while( ( n = n >> 1 ) > 0 ){
		++distance;
		if( n % 2 && n > 1 ){
			exponent2 = false;
		}
	}

	return (exponent2 ? distance : distance + 1);
}

int main()
{
	std::cout << "number : ";
	std::string strn;
	std::cin >> strn;
	int n = std::stoi( strn );
	std::cout << "  ans = " << sumTatakuT( n ) << "\n";
	return 0;
}
0