結果

問題 No.2766 Delicious Multiply Spice
ユーザー daiotadaiota
提出日時 2024-06-01 01:03:28
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 668 bytes
コンパイル時間 2,060 ms
コンパイル使用メモリ 168,084 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-12-21 02:49:17
合計ジャッジ時間 3,122 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 8
other AC * 31
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int,int> P;
#define REP(i,n) for(int i=0;i<int(n);i++)


string ans;
void dfs(ll x,string s){

	
	if(x==1){
		reverse(s.begin(),s.end());
		ans=s;
		return;
	}
	
	
	if((x-1)%2!=0 && (x-1)%3!=0) return;


	string t=s;
	   	if((x-1)%2==0){
	    		s+="A";
	    		dfs((x-1)/2,s);
	    }

	   	if((x-1)%3==0){
	    		t+="B";
	    		dfs((x-1)/3,t);
	    }


}


int main(){
	cin.tie(nullptr);  ios_base::sync_with_stdio(false);
    int i,j,k;


    ll N;
    cin >> N;

    if(N==1){
    	cout << "" << endl;
    	return 0;
    }

    dfs(N,"");


    cout << ans << endl;




	return 0;

}
0