結果

問題 No.939 and or
ユーザー kanra824kanra824
提出日時 2019-12-13 00:33:18
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 1,166 bytes
コンパイル時間 1,721 ms
コンパイル使用メモリ 173,048 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-06-26 01:24:10
合計ジャッジ時間 2,823 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  ll a, b; cin >> a >> b;

  vvll dp(32, vll(2, 0));
  dp[0][0] = 1;

  for(int i=0;i<31;++i) {
    
    int ta = (a>>(30-i))&1, tb = (b>>(30-i))&1;
    //cout << ta << ":" << tb << endl;
    if((ta == 0 && tb == 0) || (ta == 1 && tb == 1)) {
      dp[i+1][0] = dp[i][0];
      dp[i+1][1] = dp[i][1];
    } else if(ta == 0 && tb == 1) {
      dp[i+1][0] = 0;
      dp[i+1][1] = dp[i][0] + 2 * dp[i][1];
    } else {
      cout << 0 << endl;
      return 0;
    }
  }

  cout << dp[31][0] + dp[31][1] << endl;
}
0