結果

問題 No.2766 Delicious Multiply Spice
ユーザー FplusFplusFFplusFplusF
提出日時 2024-05-31 21:31:28
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 944 bytes
コンパイル時間 3,304 ms
コンパイル使用メモリ 255,396 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-12-20 22:31:08
合計ジャッジ時間 4,659 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 8
other AC * 19 WA * 12
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll,ll>;
using ld=long double;
const ll INF=(1ll<<60);
#define rep(i,n) for (ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(),v.end()
template<class T> inline bool chmin(T &a,T b){
    if(a>b){
        a=b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T &a,T b){
    if(a<b){
        a=b;
        return true;
    }
    return false;
}
map<ll,string> mp;
string f(ll x){
    if(mp.contains(x)) return mp[x];
    if(x==1){
        return "";
    }
    string ret="X";
    if((x-1)%2==0){
        ret=f((x-1)/2);
        ret.push_back('A');
    }
    if((x-1)%3==0){
        string s=f((x-1)/3);
        if(s!="X"){
            ret=s;
            ret.push_back('B');
        }
    }
    return mp[x]=ret;
}
int main(){
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    cout << f(n) << '\n';
}
0