Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
第一次优先队列 纠结的过了 0ms~~~~~#include<iostream> #include<functional> #include<vector> #include<queue> using namespace std; int main (void) { int n; int i,j,k; int a; int b[5],c; b[1]=2; b[2]=3; b[3]=5; priority_queue<int, vector<int>, greater<int> >q; // priority_queue<int , vector<int>, greater<int> >qi; int count; while(scanf("%d",&n),n!=0) { q.push(b[1]); q.push(b[2]); q.push(b[3]); // count=0; for(j=1;j<n-1;j++) { a=q.top(); for(i=1;i<=3;i++) { c=a*b[i]; if(c>0) q.push(c); } q.pop(); while(1) { k=q.top(); if(k==a) { q.pop(); } else break; } } // c=q.top(); if(n>1) printf("%d\n",q.top()); else printf("%d\n",1); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator