/* User ID: turing_13 Link : http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=show_problem&problem=72 */ #include<iostream> #include<cstdio> #include<cmath> #include<algorithm> using namespace std; int main() { double a,b,c,k,ara[2000]; int count=0; for(a=0; a<31; a++) for(b=0; b<31; b++) for(c=0; c<31; c++) { k=pow(2,c)*pow(3,b)*pow(5,a); if(k>1000000000) { k=0; break; } else { ara[count]=k; count++; } } sort(ara,ara+count); printf("The 1500'th ugly number is %.lf.\n",ara[1499]); return 0; }
Subscribe
Login
0 Comments