ccbeginner

UVa Q136

Feb 23rd, 2020
121
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //UVa Q136
  2. /******************************************************************************
  3.  
  4.                               Online C++ Compiler.
  5.                Code, Compile, Run and Debug C++ program online.
  6. Write your code in this editor and press "Run" button to compile and execute it.
  7.  
  8. *******************************************************************************/
  9.  
  10. #include <bits/stdc++.h>
  11. using namespace std;
  12. #define int long long
  13.  
  14. int32_t main(){
  15.     priority_queue<int, vector<int>, greater<int>> pq;
  16.     pq.push(1);
  17.     for(int i = 0; i < 1499; ++i){
  18.         int tmd = pq.top();
  19.         while(!pq.empty() && pq.top() == tmd)pq.pop();
  20.         pq.push(tmd*2);
  21.         pq.push(tmd*3);
  22.         pq.push(tmd*5);
  23.     }
  24.     cout << "The 1500'th ugly number is " << pq.top() << '.' << endl;
  25.     return 0;
  26. }
RAW Paste Data