結果
問題 |
No.2766 Delicious Multiply Spice
|
ユーザー |
|
提出日時 | 2024-05-31 23:09:36 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 663 bytes |
コンパイル時間 | 1,956 ms |
コンパイル使用メモリ | 168,892 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-12-21 01:30:03 |
合計ジャッジ時間 | 2,975 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 8 |
other | AC * 23 WA * 8 |
ソースコード
#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(int x,string s){ if((x-1)%2!=0 && (x-1)%3!=0) return; if(x==1){ reverse(s.begin(),s.end()); ans=s; 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; }