結果
| 問題 |
No.2766 Delicious Multiply Spice
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-05-31 23:00:18 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 805 bytes |
| コンパイル時間 | 2,160 ms |
| コンパイル使用メモリ | 206,092 KB |
| 最終ジャッジ日時 | 2025-02-21 18:26:29 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 8 |
| other | AC * 31 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr int MOD=998244353;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define replr(i,l,r) for(int i=(l);i<(int)(r);i++)
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
ll N;
cin>>N;
priority_queue<ll>pq;
map<int,pair<char,int>>memo;
pq.push(N);
while(pq.size()){
ll v=pq.top();
pq.pop();
if((v-1)%3==0){
ll v2=(v-1)/3;
if(memo.find(v2)==memo.end()){
memo[v2]=make_pair('B',v);
pq.push(v2);
}
}
if((v-1)%2==0){
ll v2=(v-1)/2;
if(memo.find(v2)==memo.end()){
memo[v2]=make_pair('A',v);
pq.push(v2);
}
}
}
ll x=1;
while(memo.find(x)!=memo.end()){
cout<<memo[x].first;
x=memo[x].second;
}
cout<<'\n';
}