結果
問題 | No.683 Two Operations No.3 |
ユーザー |
![]() |
提出日時 | 2018-09-06 12:38:34 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 763 bytes |
コンパイル時間 | 1,660 ms |
コンパイル使用メモリ | 176,596 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-21 17:32:10 |
合計ジャッジ時間 | 2,319 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 16 |
ソースコード
#include <bits/stdc++.h> using namespace std; using int64 = long long; using uint64 = unsigned long long; map<pair<int64, int64>, bool> memo; int64 f(int64 A, int64 B) { if (A < B) swap(A, B); if (memo.count({A, B})) { return memo[{A, B}]; } else if (B == 0) { return (memo[{A, B}] = true); } bool res = false; if (A % 2 == 0 and B - 1 >= 0) { res = res || f(A / 2, B - 1); } if (B % 2 == 0 and A - 1 >= 0) { res = res || f(A - 1, B / 2); } return (memo[{A, B}] = res); } int main() { cin.tie(nullptr); ios::sync_with_stdio(false); int64 A, B; cin >> A >> B; if (f(A, B)) cout << "Yes" << endl; else cout << "No" << endl; return 0; }