結果

問題 No.2766 Delicious Multiply Spice
ユーザー matcharate12
提出日時 2022-07-28 10:21:20
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 1,166 bytes
コンパイル時間 1,932 ms
コンパイル使用メモリ 173,232 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-12-20 22:03:42
合計ジャッジ時間 3,050 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 8
other AC * 23 WA * 8
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <chrono>
#define rep(i,n) for(int i = 0; i < n; i++)
#define rrep(i,a,b) for(int i = a; i < b; i++)
#define all(A) (A).begin(),(A).end()
#define MOD 1000000007
#define grt greater<int>()
#define mapf(M) for(auto& [k,v] : M)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using pq = priority_queue<ll,vector<ll>,greater<ll>>;
ll INF = 1LL<<60;
template <typename T>
bool chmax(T &a,T &b){ if(a < b){ a = b; return true; } return false; }
template <typename T>
bool chmin(T &a,T &b){ if(a > b){ a = b; return true; } return false; }
struct Edge { int to; int cost; int from; };
using Graph = vector<vector<Edge>>;
using vi = vector<int>;

void dfs(string s,vector<string>& ans,int x){
	if(x == 1) return;

	x--;
	if(x%2 == 0 && x/2 >= 1){
		s.push_back('A');
		dfs(s,ans,x/2);
		if(x/2 == 1) ans.push_back(s);
		s.pop_back();
	}
	if(x%3 == 0 && x/3 >= 1){
		s.push_back('B');
		dfs(s,ans,x/3);
		if(x/3 == 1) ans.push_back(s);
		s.pop_back();
	}
	return;
}

int main(void){
	int n; cin >> n;
	vector<string> S;
	string s = "";
	dfs(s,S,n);
	for(string& d:S) reverse(all(d));
	for(string& d:S) cout << d << endl;
}

0