結果
問題 |
No.2766 Delicious Multiply Spice
|
ユーザー |
|
提出日時 | 2024-09-08 19:33:43 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 531 bytes |
コンパイル時間 | 2,180 ms |
コンパイル使用メモリ | 204,772 KB |
最終ジャッジ日時 | 2025-02-24 05:48:40 |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 8 |
other | AC * 31 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll=long long; map<ll,string> MP; string D(ll N){ if(N==1)return ""; else if(MP.count(N))return MP[N]; string res="?"; if(N%2==1){ string T=D(N/2); if(T!="?"){ MP[N]=T+"A"; return MP[N]; } } if(N%3==1){ string T=D(N/3); if(T!="?"){ MP[N]=T+"B"; return MP[N]; } } MP[N]=res; return res; } int main() { ll N; cin>>N; cout<<D(N)<<endl; }