結果

問題 No.2766 Delicious Multiply Spice
ユーザー nononnonon
提出日時 2024-05-31 21:34:29
言語 C++17(gcc12)
(gcc 12.3.0 + boost 1.87.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 638 bytes
コンパイル時間 2,231 ms
コンパイル使用メモリ 202,696 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-12-20 22:38:19
合計ジャッジ時間 3,576 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 8
other AC * 31
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    long long N;
    cin>>N;
    string ans;
    auto f=[&](auto f, long long v)->void
    {
        if(v<1)return;
        if(v==1)
        {
            reverse(ans.begin(),ans.end());
            cout<<ans<<endl;
            return;
        }
        if((v-1)%2==0)
        {
            ans.push_back('A');
            f(f,(v-1)/2);
            ans.pop_back();
        }
        if((v-1)%3==0)
        {
            ans.push_back('B');
            f(f,(v-1)/3);
            ans.pop_back();
        }
    };
    f(f,N);
}
0