結果
問題 | No.2766 Delicious Multiply Spice |
ユーザー |
|
提出日時 | 2024-05-31 21:43:52 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 790 bytes |
コンパイル時間 | 7,641 ms |
コンパイル使用メモリ | 336,288 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-12-20 22:58:42 |
合計ジャッジ時間 | 7,530 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 8 |
other | AC * 31 |
ソースコード
#include <bits/stdc++.h>using namespace std;#include <atcoder/all>using namespace atcoder;#define ll long long#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)//using mint = modint998244353;const int dx[4]={0,1,0,-1};const int dy[4]={1,0,-1,0};ll n;string f(ll x, string a) {if (x == 1) return a;if((x-1ll)%2ll==0){string res = f((x-1ll)/2ll, a + 'A');if (!res.empty()){return res;}}if((x-1ll)%3ll==0){string res2 = f((x-1ll)/ 3ll, a + 'B');if (!res2.empty()){return res2;}}return "";}int main() {cin >> n;ll x = 1;string a;a = f(n, "");reverse(a.begin(),a.end());cout << a << endl;return 0;}