Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //UVa Q136
- /******************************************************************************
- Online C++ Compiler.
- Code, Compile, Run and Debug C++ program online.
- Write your code in this editor and press "Run" button to compile and execute it.
- *******************************************************************************/
- #include <bits/stdc++.h>
- using namespace std;
- #define int long long
- int32_t main(){
- priority_queue<int, vector<int>, greater<int>> pq;
- pq.push(1);
- for(int i = 0; i < 1499; ++i){
- int tmd = pq.top();
- while(!pq.empty() && pq.top() == tmd)pq.pop();
- pq.push(tmd*2);
- pq.push(tmd*3);
- pq.push(tmd*5);
- }
- cout << "The 1500'th ugly number is " << pq.top() << '.' << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment