結果
問題 | No.939 and or |
ユーザー | ransewhale |
提出日時 | 2019-12-08 06:32:08 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 760 bytes |
コンパイル時間 | 2,076 ms |
コンパイル使用メモリ | 166,216 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-28 05:21:40 |
合計ジャッジ時間 | 3,917 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 30 |
ソースコード
#include "bits/stdc++.h" using namespace std; typedef long long ll; typedef pair<int, char> P; const int INF = (1<<30); const ll INFLL = (1ll<<60); const ll MOD = (ll)(1e9+7); #define l_ength size void mul_mod(ll& a, ll b){ a *= b; a %= MOD; } void add_mod(ll& a, ll b){ a = (a<MOD)?a:(a-MOD); b = (b<MOD)?b:(b-MOD); a += b; a = (a<MOD)?a:(a-MOD); } ll dp[33][2]; int main(void){ ll a,b,i,j,x,y; dp[32][0] = 1ll; cin >> a >> b; for(i=31; i>=0; --i){ for(j=0; j<2; ++j){ for(x=0; x<2; ++x){ for(y=0; y<2; ++y){ if((!j)&&(x>y)){ continue; } if(!(((a>>i)&1ll)==(x&y)&&((b>>i)&1ll)==(x|y))){ continue; } dp[i][j|(x<y)] += dp[i+1][j]; } } } } cout << (dp[0][0]+dp[0][1]) << endl; return 0; }