結果
| 問題 | No.2766 Delicious Multiply Spice |
| コンテスト | |
| ユーザー |
kokosei
|
| 提出日時 | 2024-06-01 13:20:05 |
| 言語 | C++23 (gcc 15.3.0 + boost 1.92.0 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 1 ms / 2,000 ms |
| + 404µs | |
| コード長 | 672 bytes |
| 記録 | |
| コンパイル時間 | 1,320 ms |
| コンパイル使用メモリ | 176,840 KB |
| 実行使用メモリ | 9,916 KB |
| 最終ジャッジ日時 | 2026-10-05 18:28:14 |
| 合計ジャッジ時間 | 3,431 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 8 |
| other | AC * 31 |
ソースコード
#include <iostream>
#include <algorithm>
#include <string>
#include <map>
using namespace std;
using ll = long long;
const string no = "#";
map<ll, string> memo;
string calc(ll n){
if(n == 1)return "";
if(memo.find(n) != memo.end())return memo[n];
string res = no;
if((n - 1) % 2 == 0){
string a = calc((n - 1) / 2);
if(a != no)res = a + "A";
}
if((n - 1) % 3 == 0){
string a = calc((n - 1) / 3);
if(a != no)res = a + "B";
}
return memo[n] = res;
}
ll N;
int main(void){
ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> N;
string s = calc(N);
cout << s << endl;
return 0;
}
kokosei