唉,这题实在不会用动态规划的方法,,我比较无脑
首先,在A数组中只放1
然后,枚举在2e9以内的2的所有倍数,比如2^1,2^2,2^3,,........
拿这些数去分别乘以A数组中以前有的数字,并加入到A数组的末尾
然后,枚举在2e9以内的3的所有倍数,比如3^1,3^2,3^3,,........
拿这些数去分别乘以A数组中上一次操作后有的数字,并加入到A数组的末尾
5也同理,,随后把这些数字排序,然后去重,,打表搞定23333
#include<cstdio>
#include<cmath>
#include<cstring>
#include<queue>
#include<vector>
#include<ctime>
#include<functional>
#include<algorithm>using namespace std;
typedef long long LL;
typedef pair<int, int> PII;const int MX = 1e6;
const int INF = 0x3f3f3f3f;int A[MX + 5], rear = 0, w[] = {2, 3, 5};void init() {rear = 1;A[1] = 1;for(int k = 0; k < 3; k++) {for(LL p = w[k]; p < 2e9; p *= w[k]) {int tot = rear;for(int i = 1; i <= tot; i++) {if(p * A[i] < 2e9) A[++rear] = p * A[i];}}}sort(A + 1, A + 1 + rear);rear = unique(A + 1, A + 1 + rear) - A - 1;
}int main() {init();int n;while(~scanf("%d", &n), n) {printf("%d\n", A[n]);}return 0;
}