結果
問題 |
No.2766 Delicious Multiply Spice
|
ユーザー |
![]() |
提出日時 | 2024-05-31 21:25:41 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 76 ms / 2,000 ms |
コード長 | 692 bytes |
コンパイル時間 | 2,143 ms |
コンパイル使用メモリ | 200,904 KB |
最終ジャッジ日時 | 2025-02-21 17:27:47 |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 8 |
other | AC * 31 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; const int INF = 1e9 + 10; const ll INFL = 4e18; int main() { ll N; cin >> N; map<ll, bool> mp; string ans; auto F = [&](auto&& F, ll n) -> bool { if (n == 1) { return true; } if (mp.count(n)) { return mp[n]; } if ((n - 1) % 2 == 0 && F(F, (n - 1) / 2)) { ans.push_back('A'); return mp[n] = true; } if ((n - 1) % 3 == 0 && F(F, (n - 1) / 3)) { ans.push_back('B'); return mp[n] = true; } return mp[n] = false; }; F(F, N); cout << ans << endl; }