結果

問題 No.589 Counting Even
ユーザー 👑 CleyL
提出日時 2024-02-13 23:09:59
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 326 bytes
コンパイル時間 768 ms
コンパイル使用メモリ 65,664 KB
最終ジャッジ日時 2025-02-19 06:04:35
ジャッジサーバーID
(参考情報)
judge2 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 29
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
using namespace std;
int main(){
  long long n;cin>>n;
  if(n <= 1)cout << 0 << endl;
  else{
    long long mx2 = 1;
    while(mx2 <= n)mx2*=2;
    mx2/=2;
    long long ans = 1;
    while(mx2){
      if(n & mx2){
        ans++;;
      }
      mx2 /= 2;
    }
    cout << n-(1LL<<(ans-1))+1 << endl;
  }
}
0