結果

問題 No.683 Two Operations No.3
ユーザー hanbei_dayohanbei_dayo
提出日時 2020-09-03 11:33:55
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 1,001 bytes
コンパイル時間 721 ms
コンパイル使用メモリ 83,408 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-05-02 11:41:56
合計ジャッジ時間 1,424 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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<0){
        return false;
    }
    if(B<0){
        return false;
    }
    if(A==0 && B==0){
        return true;
    }
    if(A==0){
        return true;
    }
    if(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