結果
問題 |
No.680 作れる数
|
ユーザー |
|
提出日時 | 2018-04-28 00:52:40 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 518 bytes |
コンパイル時間 | 1,536 ms |
コンパイル使用メモリ | 165,764 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-27 23:09:10 |
合計ジャッジ時間 | 2,198 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 20 |
ソースコード
#include <bits/stdc++.h> #define ll long long using namespace std; ll game(ll x) { ll ret = 0; while(x>0) { ret += x; x/=2; } return ret; } int main() { ll n; cin >> n; if(n==0) { cout << "YES" << endl; return 0; } ll ok = 1; ll ng = 10000000001L; while(abs(ok-ng)>1) { ll test = (ok+ng)/2; if(game(test)<=n) { ok = test; } else { ng = test; } } if(game(ok)==n) { cout << "YES" << endl; } else { cout << "NO" << endl; } return 0; }