結果
問題 | No.683 Two Operations No.3 |
ユーザー |
|
提出日時 | 2018-05-12 17:01:07 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 7 ms / 2,000 ms |
コード長 | 708 bytes |
コンパイル時間 | 2,229 ms |
コンパイル使用メモリ | 200,148 KB |
最終ジャッジ日時 | 2025-01-05 10:34:25 |
ジャッジサーバーID (参考情報) |
judge1 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 16 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { ll A, B; cin >> A >> B; using P = pair<ll, ll>; map<P, bool> memo; auto ok = [&](auto&& self, ll A, ll B) -> bool { if (A == 0 or B == 0) { return true; } if (A % 2 == 1 and B % 2 == 1) { return false; } if (A > B) { swap(A, B); } if (memo.find(P{A, B}) != memo.end()) { return memo[{A, B}]; } if (A % 2 == 0 and self(self, A / 2, B - 1)) { return memo[{A, B}] = true; } if (B % 2 == 0 and self(self, A - 1, B / 2)) { return memo[{A, B}] = true; } return memo[{A, B}] = false; }; cout << (ok(ok, A, B) ? "Yes" : "No") << endl; return 0; }