結果
| 問題 | No.683 Two Operations No.3 | 
| コンテスト | |
| ユーザー |  どらら | 
| 提出日時 | 2018-05-12 00:35:43 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 2 ms / 2,000 ms | 
| コード長 | 1,022 bytes | 
| コンパイル時間 | 1,512 ms | 
| コンパイル使用メモリ | 167,988 KB | 
| 実行使用メモリ | 6,944 KB | 
| 最終ジャッジ日時 | 2024-06-28 09:57:22 | 
| 合計ジャッジ時間 | 2,173 ms | 
| ジャッジサーバーID (参考情報) | judge4 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 16 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;
bool check(ll A, ll B){
  if(A == 0 || B == 0) return true;
  if(A < 0 || B < 0) return false;
  
  if(A > B){
    if(A%2==0 && B>0){
      if(check(A/2,B-1)) return true;
    }
    if(B%2==0 && A>0){
      if(check(A-1,B/2)) return true;
    }
  }else{
    if(B%2==0 && A>0){
      if(check(A-1,B/2)) return true;
    }
    if(A%2==0 && B>0){
      if(check(A/2,B-1)) return true;
    }
  }
  return false;
}
int main(){
  ll A, B;
  cin >> A >> B;
  if(A > B) swap(A,B);
  if(A==0){
    cout << "Yes" << endl;
    return 0;
  }
  if(A==1){
    if(B%2==0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
  }
  
  if(check(A,B)) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}
            
            
            
        