結果

問題 No.683 Two Operations No.3
ユーザー jupirojupiro
提出日時 2020-03-11 20:12:49
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
MLE  
実行時間 -
コード長 1,597 bytes
コンパイル時間 1,397 ms
コンパイル使用メモリ 121,388 KB
実行使用メモリ 814,848 KB
最終ジャッジ日時 2024-11-16 00:22:20
合計ジャッジ時間 19,053 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 5 WA * 1 MLE * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int inf = 1 << 28;
constexpr long long mod = 1000000007LL;
//constexpr long long mod = 998244353LL;

using namespace std;
typedef unsigned long long ull;
typedef long long ll;

ll A, B;
map<pair<ll, ll>, int> mp;
bool dfs(ll X, ll Y) {
	if (mp.find({ X, Y }) != mp.end()) return mp[make_pair(X, Y)];
	if (X == A && Y == B) return true;
	if (X > A || Y > B) return false;
	bool flag = false;
	flag |= dfs(X + 1, Y * 2);
	if (flag) return mp[{X, Y}] = true;
	flag |= dfs(X * 2, Y + 1);
	return mp[{X, Y}] = true;
}
int main()
{
	/*
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	*/
	scanf("%lld %lld", &A, &B);
	if (A == 0 || B == 0) {
		puts("Yes");
		return 0;
	}
	bool flag = false;
	flag |= dfs(0, 1);
	flag |= dfs(1, 0);
	if (flag) puts("Yes");
	else puts("No");
	return 0;
	/*
		おまじないを使ったらscanfとprintf関連注意!!!!!!!!!!!!
	*/
}
0