結果

問題 No.683 Two Operations No.3
ユーザー hiro71687khiro71687k
提出日時 2023-03-31 03:54:46
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,184 bytes
コンパイル時間 5,251 ms
コンパイル使用メモリ 265,848 KB
実行使用メモリ 4,372 KB
最終ジャッジ日時 2023-10-23 17:35:17
合計ジャッジ時間 6,454 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,372 KB
testcase_01 AC 2 ms
4,372 KB
testcase_02 AC 2 ms
4,372 KB
testcase_03 AC 2 ms
4,372 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 2 ms
4,372 KB
testcase_07 AC 2 ms
4,372 KB
testcase_08 AC 2 ms
4,372 KB
testcase_09 WA -
testcase_10 AC 2 ms
4,372 KB
testcase_11 AC 2 ms
4,372 KB
testcase_12 WA -
testcase_13 AC 2 ms
4,372 KB
testcase_14 AC 2 ms
4,372 KB
testcase_15 AC 2 ms
4,372 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll=long long;
using ld=long double;
ld pie=3.141592653589793;
ll mod=1000000007;
ll inf=999999999999999999;
int main(){
    ll x,y;
    cin >> x >> y;
    queue<pair<ll,ll>>que;
    que.push({x,y});
    while (!que.empty())
    {
        ll a=que.front().first;
        ll b=que.front().second;
        que.pop();
        if (a==0||b==0)
        {
            cout << "Yes" << endl;
            return 0;
        }
        
        if (a%2&&b%2)
        {
            continue;
        }
        if (a%2)
        {
            a-=1;
            b/=2;
            que.push({a,b});
        }else if (b%2)
        {
            b-=1;
            a/=2;
            que.push({a,b});
        }else{
            if ((a/2)%2)
            {
                a-=1;
                b/=2;
                que.push({a,b});
            }else if ((b/2)%2)
            {
                b-=1;
                a/=2;
                que.push({a,b});
            }else{
                a-=1;
                b/=2;
                que.push({a,b});
            }
        }
    }
    cout << "No" << endl;
}
0