結果

問題 No.47 ポケットを叩くとビスケットが2倍
ユーザー sansaquasansaqua
提出日時 2019-08-07 21:52:44
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 1,178 bytes
コンパイル時間 686 ms
コンパイル使用メモリ 77,664 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-25 23:17:38
合計ジャッジ時間 1,808 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,384 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 1 ms
4,384 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 1 ms
4,384 KB
testcase_21 AC 1 ms
4,376 KB
testcase_22 AC 1 ms
4,376 KB
testcase_23 AC 2 ms
4,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <utility>
#include <set>
#include <list>
#include <cassert>
#include <queue>
#include <cmath>
#include <algorithm>

using namespace std;
using ll = long long int;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define YES(n) std::cout << ((n) ? "YES" : "NO"  ) << "\n";
#define Yes(n) std::cout << ((n) ? "Yes" : "No" ) << "\n";

#define ALL_INCLUDED_ENVIRONMENT

template <class T, class Alloc, template <class, class> class C> std::ostream& operator<<(std::ostream& o, const C<T, Alloc>& v) {
  o << "{";
  bool init = 1;
  for (auto e : v) {
    if (init) { init = 0; }
    else { o << ", "; }
    o << e;
  }
  o << "}";
  return o;
}

int int_width (ll x) {
  int ans = 0;
  while(x > 0) {
    x = x >> 1;
    ans++;
  }
  return ans;
}

int popcnt(uint64_t n)
{
    return __builtin_popcountll(n);
}

int tzcnt(uint64_t n)
{
    return n == 0 ? 64 : __builtin_ctzll(n);
}

int lzcnt(uint64_t n)
{
    return n == 0 ? 64 : __builtin_clzll(n);
}

int main() {
  // cin.tie(0);
  // ios::sync_with_stdio(false);
  ll n;
  cin >> n;
  ll ans = int_width(n);
  if (popcnt(n) == 1) ans--;
  cout << ans << "\n";
  return 0;
}
0