結果
| 問題 |
No.2766 Delicious Multiply Spice
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-06-08 15:46:20 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 656 bytes |
| コンパイル時間 | 1,736 ms |
| コンパイル使用メモリ | 167,540 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-12-28 02:30:32 |
| 合計ジャッジ時間 | 3,125 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 8 |
| other | AC * 31 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=0; i<(int)n; i++)
using ll = long long int;
int main() {
ll N;
cin >> N;
auto dfs = [&](auto dfs, ll x, string S) {
if (x == 1) {
rep(i, (int)S.size())
cout << S[(int)S.size() - 1 - i];
cout << endl;
return true;
}
if (x < 1)
return false;
bool ret = false;
if ((x - 1) % 2 == 0)
ret = (dfs(dfs, (x -1) / 2, S + "A")) || ret;
if ((x - 1) % 3 == 0)
ret = (dfs(dfs, (x-1) / 3, S + "B")) || ret;
if ((x - 1) % 2 != 0 && (x - 1) % 3 != 0)
ret = false;
return ret;
};
dfs(dfs, N, "");
return 0;
}