typedeflonglongll;usingnamespacestd;structcmp{booloperator()(constll&a,constll&b){returna>b;}};intmain(){set<ll>S;priority_queue<ll,vector<ll>,cmp>Q;S.insert(1);Q.push(1);for(inti=1;;i++){lla=Q.top();Q.pop();if(i==1500){cout<<"The 1500'th ugly number is "<<a<<"."<<endl;break;}if(S.find(a*2)==S.end()){S.insert(a*2);Q.push(a*2);}if(S.find(a*3)==S.end()){S.insert(a*3);Q.push(a*3);}if(S.find(a*5)==S.end()){S.insert(a*5);Q.push(a*5);}}}
include