HDU 1058 Humble Numbers DP

 

 

思路:所有的数均为 2^a*3^b*5^c*7^d 构成

 

因为因子一共只有4个, 一个humble number可以写成2^a*3^b*5^c*7^d的形式;
        然后枚举abcd,计算出每一个humble number,再排序即可!
但是注意从小到大排序
#include
#include
#include
using namespace std;
#define N 6000
int a[N], c[4];
int main()
{
    int x, y, z, w;
    x = y = w = z = 1;
    a[0] = 1;
    int temp;
    for (int i = 1; i

 

 

 

你可能感兴趣的:(#,其他)