136 - Ugly Numbers
136 Accepted View Problem UVA Problem: 136 - Ugly Numbers Time Limit: 3.00 Seconds Program Language: C++ Publisher: http://www.uvaonlinejudge.org ♣ Try it Out :: #include<iostream> using namespace std; int main() { int p,q,r, i=1, P,Q,R, ugly[1501]={0}; ugly[0]=1, p=q=r=0; while(ugly[1499] == 0) { P = ugly[p]*2; Q = ugly[q]*3; R = ugly[r]*5; if(P<Q && P<R) {ugly[i++]=P; p++;} else if(Q<P && Q<R) {ugly[i++]=Q; q++;} else if(R<P && R<Q) {ugly[i++]=R; r++;} else if(P == Q) {q++;} else if(P == R) {r++;} else if(R == Q) {r++;} } cout<<"The 1500'th ugly number is "<<ugly[1499]<<"."<<endl; return(0); } ♣ Source Codes :: 136 - Ugly Numbers.cpp 136 - Ugly Numbers.java আবূ হুরাইরাহ (রাঃ) হতে বর্ণিত আছে, তিনি বলেন, নবী (সাল্লাল্