http://poj.org/problem?id=1338
找出前1500小的 n=2^i*3^j*5^k;
直接爆搜
#include <cmath>
#include <cstdio>
#include <cstring>
#include <limits>
#include <string>
#include <iostream>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
using namespace std;
const int inf=2147483647;
int tm[1555];
int min(int a,int b){return a<b?a:b;}
int min(int a,int b,int c){return min(min(a,b),c);}
int main()
{
int n;
int i;
int p5,p2,p3;
int ok=0;
tm[++ok]=1;
p2=p3=p5=1;
int c2,c3,c5;
for (i=1;i<=1500;i++)
{
int minn=inf;
c2=tm[p2]*2;
c3=tm[p3]*3;
c5=tm[p5]*5;
minn=min(c2,c3,c5);
if (minn==c2) ++p2;
if (minn==c3) ++p3;
if (minn==c5) ++p5;
tm[++ok]=minn;
}
while(scanf("%d",&n)&&n)
{
printf("%d\n",tm[n]);
}
return 0;
}