結果
問題 | No.2766 Delicious Multiply Spice |
ユーザー | Nzt3 |
提出日時 | 2024-05-31 23:00:18 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 805 bytes |
コンパイル時間 | 2,485 ms |
コンパイル使用メモリ | 212,924 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-21 01:12:06 |
合計ジャッジ時間 | 3,817 ms |
ジャッジサーバーID (参考情報) |
judge5 / 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'; }