結果

問題 No.680 作れる数
ユーザー tetsutetsu
提出日時 2018-04-28 00:17:26
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 456 bytes
コンパイル時間 1,506 ms
コンパイル使用メモリ 165,252 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-06-27 23:02:45
合計ジャッジ時間 15,190 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 19 TLE * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define ll long long
using namespace std;
bool dfs(const ll t, const ll s, const ll n) {
  // printf("dfs(%lld, %lld, %lld\n", t, s, n);
  if(s==n) return true;
  if(s>n) return false;
  ll next1 = 2*t;
  ll next2 = next1+1;
  return dfs(next1,s+next1, n) || dfs(next2, s+next2, n);
}
int main() {
  ll n;
  cin >> n;
  if(n == 0 || dfs(1, 1, n)) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}
0