結果

問題 No.680 作れる数
ユーザー beetbeet
提出日時 2018-04-27 22:57:40
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 15 ms / 2,000 ms
コード長 575 bytes
コンパイル時間 1,587 ms
コンパイル使用メモリ 172,600 KB
実行使用メモリ 5,192 KB
最終ジャッジ日時 2023-09-10 06:41:12
合計ジャッジ時間 2,859 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 10 ms
4,964 KB
testcase_01 AC 14 ms
4,956 KB
testcase_02 AC 10 ms
4,896 KB
testcase_03 AC 10 ms
4,964 KB
testcase_04 AC 10 ms
4,888 KB
testcase_05 AC 13 ms
4,908 KB
testcase_06 AC 10 ms
4,948 KB
testcase_07 AC 14 ms
4,944 KB
testcase_08 AC 10 ms
4,892 KB
testcase_09 AC 10 ms
4,904 KB
testcase_10 AC 10 ms
5,004 KB
testcase_11 AC 10 ms
4,904 KB
testcase_12 AC 12 ms
4,952 KB
testcase_13 AC 14 ms
4,912 KB
testcase_14 AC 13 ms
4,948 KB
testcase_15 AC 15 ms
5,192 KB
testcase_16 AC 11 ms
4,892 KB
testcase_17 AC 15 ms
4,952 KB
testcase_18 AC 13 ms
5,120 KB
testcase_19 AC 15 ms
4,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//INSERT ABOVE HERE
signed main(){
  Int n;
  cin>>n;
  
  vector<Int> v({1});
  for(Int i=0;i<30;i++)
    v.emplace_back(Int(v.back()<<1|1));
  
  Int h=15;
  set<Int> s;
  for(Int b=0;b<(1<<h);b++){
    Int x=0;
    for(Int i=0;i<h;i++)
      if((b>>i)&1) x+=v[i];
    s.emplace(x);
  }
  
  for(Int b=0;b<(1<<(30-h));b++){
    Int x=0;
    for(Int i=0;i<(30-h);i++)
      if((b>>i)&1) x+=v[h+i];
    if(s.count(n-x)){
      cout<<"YES"<<endl;
      exit(0);
    }
  }
  cout<<("NO")<<endl;
  return 0;
}
0