結果

問題 No.2853 A + B Problem
ユーザー ryota2357
提出日時 2024-08-20 19:38:54
言語 C++17(clang)
(17.0.6 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 332 bytes
コンパイル時間 855 ms
コンパイル使用メモリ 130,632 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-08-20 19:38:59
合計ジャッジ時間 2,007 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 9 WA * 11
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:11:16: warning: result of comparison of constant 1073741824 with expression of type 'bool' is always true [-Wtautological-constant-out-of-range-compare]
   11 |         assert(1 <= n < (1LL << 30));
      |                ~~~~~~ ^ ~~~~~~~~~~~
/usr/include/assert.h:93:27: note: expanded from macro 'assert'
   93 |      (static_cast <bool> (expr)                                         \
      |                           ^~~~
1 warning generated.

ソースコード

diff #

#include <iostream>
#include <cassert>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long;

int main() {
	ll n; 
	cin >> n;
	assert(1 <= n < (1LL << 30));
	
	int bcnt = 0;
	for (int i = 0; i < 30; ++i) {
		if (n & (1LL << i)) bcnt += 1;
	}
	bcnt -= 1;
	cout << (bcnt ? (1LL << bcnt) : 0) << endl;
}
0