結果
問題 |
No.2766 Delicious Multiply Spice
|
ユーザー |
![]() |
提出日時 | 2024-07-12 12:12:47 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 5 ms / 2,000 ms |
コード長 | 569 bytes |
コンパイル時間 | 1,749 ms |
コンパイル使用メモリ | 169,740 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-12 12:12:50 |
合計ジャッジ時間 | 3,301 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 8 |
other | AC * 31 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; #define rep(i, n) for(int i = 0; i < n; i++) int main() { ll N; cin >> N; string ans = ""; function<int(ll)> dfs = [&](ll x) { if(x == 1) return 0; ll nx = (x - 1) / 2; int m = (x - 1) % 2; if(m == 0 && nx > 0) { int ret = dfs(nx); if(ret == 0) { ans += "A"; return 0; } } nx = (x - 1) / 3; m = (x - 1) % 3; if(m == 0 && nx > 0) { int ret = dfs(nx); if(ret == 0) { ans += "B"; return 0; } } return -1; }; dfs(N); cout << ans << endl; }