結果

問題 No.642 Two Operations No.1
ユーザー nomi
提出日時 2018-02-02 23:47:54
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 773 bytes
コンパイル時間 1,838 ms
コンパイル使用メモリ 167,004 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-12-31 08:19:08
合計ジャッジ時間 2,268 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 15
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define rep(i, n, m) for (int (i) = (n); (i) < (m); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debugB(x, y) cerr<<#x<<": "<<bitset<y>(x) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};

int main() {
   int n;
   cin >> n;
   n--;
   int digit = 0, zero = 0;
   while (n > 0) {
      if ((n&1)==0) {
         zero++;
      }
      n = (n>>1);
      digit++;
   }
   cout << digit + zero << endl;

   return 0;
}
0