結果

問題 No.589 Counting Even
ユーザー Gurren47881
提出日時 2017-11-03 23:55:09
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 688 bytes
コンパイル時間 1,564 ms
コンパイル使用メモリ 166,448 KB
実行使用メモリ 13,824 KB
最終ジャッジ日時 2024-11-23 15:14:21
合計ジャッジ時間 57,954 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 5 WA * 6 TLE * 18
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
#define REP(i,n) for(int i = 0;i < (n);i++)
#define pb push_back

const int INF = 1e9;
 
const ll mod=1e9+7;
 
int main(){

  ll nn;
  cin >> nn;
  ll sum = 0;
  ll n = nn;
  while(n%2 == 0){
    sum++;
    n /= 2;
    if(n == 0)
      break;
  }
  //cout << sum << endl;
  ll res = 0;
  REP(i,nn/2+1){
    ll sumn = 0;
    ll r = i;
    while(r%2 == 0 && r != 0){
      sumn++;
      r /= 2;
      
    }
    //cout << sumn << endl;
    if(sum > sumn && i != 0)
      res++;
  }
  if(nn%2 == 0 && nn != 0)
    cout << (res-1)*2+1 <<endl;
  else if(nn == 0)
    cout << 0 << endl;
  else
    cout << res*2 << endl;
}
0