結果

問題 No.589 Counting Even
ユーザー vjudge1
提出日時 2025-08-25 09:33:07
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 339 bytes
コンパイル時間 1,237 ms
コンパイル使用メモリ 161,224 KB
実行使用メモリ 7,716 KB
最終ジャッジ日時 2025-08-25 09:33:09
合計ジャッジ時間 2,393 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 29
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define int long long
int n, k; 
signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cin >> n;
    for (int i = n; i; i >>= 1ll) k += (i & 1ll);
	cout << n + 1 - (1ll << k);
    return 0;
}
/*
????????C n, k = \sum C (n >> i) & 1, (k >> i) & 1 
n & k == 0 ?? 0
*/
0