日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) >

poj 1338 优先队列

發(fā)布時(shí)間:2025/7/14 34 豆豆
生活随笔 收集整理的這篇文章主要介紹了 poj 1338 优先队列 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

pair來表示推演樹上的結(jié)點(diǎn),用first表示結(jié)點(diǎn)的值,用second表示結(jié)點(diǎn)是由父結(jié)點(diǎn)乘以哪一個(gè)因子得到的。

?

1 #include <iostream> 2 #include <cstring> 3 #include <cstdio> 4 #include <algorithm> 5 #include <cmath> 6 #include <queue> 7 #include <stack> 8 #include <string> 9 #include <vector> 10 #include <utility> 11 using namespace std; 12 13 typedef pair<__int64, int> node; 14 15 const int maxn = 1e3+505; 16 __int64 ans[maxn]; 17 int n; 18 19 void init() 20 { 21 priority_queue<node,vector<node>,greater<node> > q; 22 q.push(make_pair(1,2)); 23 for(int i=1;i<=1500;i++) 24 { 25 node cur=q.top(); 26 q.pop(); 27 switch(cur.second) 28 { 29 case 2: 30 q.push(make_pair(cur.first*2,2)); 31 case 3: 32 q.push(make_pair(cur.first*3,3)); 33 case 5: 34 q.push(make_pair(cur.first*5,5)); 35 } 36 ans[i]=cur.first; 37 } 38 } 39 40 int main() 41 { 42 init(); 43 while(~scanf("%d",&n)) 44 { 45 if(!n) break; 46 printf("%I64d\n",ans[n]); 47 } 48 return 0; 49 }

?

?

?

轉(zhuǎn)載于:https://www.cnblogs.com/Missa/archive/2012/11/28/2793508.html

總結(jié)

以上是生活随笔為你收集整理的poj 1338 优先队列的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。