結果

問題 No.680 作れる数
ユーザー tetsutetsu
提出日時 2018-04-28 00:17:26
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 456 bytes
コンパイル時間 1,872 ms
コンパイル使用メモリ 164,780 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-10 07:32:16
合計ジャッジ時間 15,821 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 4 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 232 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 1,706 ms
4,376 KB
testcase_13 AC 833 ms
4,376 KB
testcase_14 AC 1,510 ms
4,376 KB
testcase_15 AC 1,354 ms
4,380 KB
testcase_16 AC 1,155 ms
4,380 KB
testcase_17 AC 1,950 ms
4,380 KB
testcase_18 TLE -
testcase_19 TLE -
権限があれば一括ダウンロードができます

ソースコード

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