#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>
using namespace std;
typedef long long LL;
const int maxn=10010;
const int N=10;
priority_queue<LL,vector<LL>,greater<LL> > pq;
int a[]={2,3,5};
int main(){
set<LL> st;
st.insert(1);
pq.push(1);
for(int i=1;;i++){
LL x=pq.top(); pq.pop();
if(i==1500){
printf("The 1500`th ugly number is %lld\n",x);
}
for(int j=0;j<3;j++){
LL x2=a[j]*x;
if(!st.count(x2)){
st.insert(x2);
pq.push(x2);
}
}
}
return 0;
}
Uva136
猜你喜欢
转载自blog.csdn.net/qq_924485343/article/details/104242407
今日推荐
周排行