結果

問題 No.680 作れる数
ユーザー cotton_fn_cotton_fn_
提出日時 2019-07-01 22:41:20
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,289 bytes
コンパイル時間 965 ms
コンパイル使用メモリ 107,616 KB
最終ジャッジ日時 2025-01-07 05:49:16
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 19 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

i64 f(i64 x) {
  i64 y = 0;
  for (; x > 0; x >>= 1) y += x;
  return y;
}

int main() {
  i64 n;
  cin >> n;
  if (n == 0) { cout << "YES\n"; return 0; }
  i64 l = 0, r = n;
  while (r - l >= 2) {
    i64 x = l + (r - l) / 2;
    i64 y = f(x);
    if (y < n) l = x; 
    else if (y > n) r = x;
    else { cout << "YES\n"; return 0; }
    cerr << x << '\t' << y << endl;
  }
  cout << "NO\n";
  return 0;
}
0