結果

問題 No.683 Two Operations No.3
ユーザー hanbei_dayohanbei_dayo
提出日時 2020-09-03 11:32:59
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
MLE  
実行時間 -
コード長 941 bytes
コンパイル時間 784 ms
コンパイル使用メモリ 83,648 KB
実行使用メモリ 818,176 KB
最終ジャッジ日時 2024-05-02 11:40:43
合計ジャッジ時間 3,726 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 MLE -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'bool dfs(ll, ll)':
main.cpp:47:1: warning: control reaches end of non-void function [-Wreturn-type]
   47 | }
      | ^

ソースコード

diff #

#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
using namespace std;
//#define N (1000000000+7)
//#define N (998244353)
#define N 17
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;

const int inf = 1e9;

bool dfs(ll A,ll B){
    if(A>B)swap(A,B);
    if(A<0){
        return false;
    }
    if(B<0){
        return false;
    }
    if(A==0 && B==0){
        return true;
    }
    if(A%2==1 && B%2==1){
        return false;
    }
    if(A%2==0 && B%2==1){
        return dfs(A/2,B-1);
    }
    if(A%2==1 && B%2==0){
        return dfs(A-1,B/2);
    }
    if(A%2==0 && B%2==0){
        return dfs(A-1,B/2)|dfs(A/2,B-1);
    }
}

int main(void){
    ll A,B;
    cin>>A>>B;
    if(dfs(A,B))cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}
0