結果

問題 No.378 名声値を稼ごう
ユーザー d2verbd2verb
提出日時 2017-09-06 17:08:09
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 878 bytes
コンパイル時間 2,016 ms
コンパイル使用メモリ 143,684 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-12 15:06:24
合計ジャッジ時間 2,424 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,384 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,384 KB
testcase_04 AC 1 ms
4,384 KB
testcase_05 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

const double pi  = 2 * acos(0.0);
const double eps = 1e-8;

#define REP(i,a,b) for(int i=(a); i<(b);++i)
#define rep(i,n) REP(i,0,n)
#define INF (1<<29)
#define INFLL (1LL<<61)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

int main(void) {
  ios_base::sync_with_stdio(false); cin.tie(0);
  ll N, T;
  cin >> N;

  ll NC = 0;
  T = N;
  while (T != 0) {
    NC += T;
    T /= 2;
  }

  ll ans = -1;
  for (int i = 0; i < 61; i++) {
    ll S = 0;
    T = N;
    for (int j = 0; T != 0; j++, T /= 2) {
      if (j == i) {
        S += T * 2;
        break;
      } else {
        S += T;
      }
    }
    ans = max(S, ans);
  }

  ans = ans - NC;

  cout << ans << endl;
  return 0; 
}
0