結果

問題 No.683 Two Operations No.3
ユーザー xxxasdfghjkxxxasdfghjk
提出日時 2018-08-13 14:42:31
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 843 bytes
コンパイル時間 857 ms
コンパイル使用メモリ 71,740 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-24 16:40:39
合計ジャッジ時間 1,225 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include<cstdio>
#include<queue>
#include<utility>
#include<cstring>
#include<stack>
#include<algorithm>
#include<cmath>
#include<iostream>
#include<map>
#define MAX_N 100001
#define INF_INT 2147483647
#define INF_LL 9223372036854775807
#define REP(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
bool solve(ll A,ll B){
  
  if(A == 0 || B == 0)
    return true;
  else if(A % 2 == 1 && B % 2 == 1)
    return false;
  else{
    if(A % 2 == 0 && B % 2 == 0){
      return solve(A/2,B-1) || solve(A-1,B/2);
    }else{
      if(A % 2 == 1)
        return solve(A-1,B/2);
      else
        return solve(A/2,B-1);
    }
  }
  
}

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

0