結果
| 問題 |
No.378 名声値を稼ごう
|
| コンテスト | |
| ユーザー |
d2verb
|
| 提出日時 | 2017-09-06 17:08:09 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 878 bytes |
| コンパイル時間 | 1,401 ms |
| コンパイル使用メモリ | 159,792 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-06-30 03:08:05 |
| 合計ジャッジ時間 | 1,815 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 5 |
ソースコード
#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;
}
d2verb