0
点赞
收藏
分享

微信扫一扫

【codevs1246】丑数


problem

solution

codes

#include<cstdio> 
int p[101], a[101], k, n;
long long ans[100001], MIN;
int main(){
ans[0]=1;
scanf("%d%d",&k,&n);
for (int i=1;i<=k;i++) scanf("%d",&p[i]);
for (int i=1;i<=n;i++){
MIN=0x7FFFFFFF;
for (int j=1;j<=k;j++){
while (p[j]*ans[a[j]] <= ans[i-1]) a[j]++;
if (MIN > p[j]*ans[a[j]]) MIN=p[j]*ans[a[j]];
}
ans[i] = MIN;
}
printf("%lld",ans[n]);
return 0;
}


举报

相关推荐

LeetCode丑数

丑数 II

超级丑数

丑数--动态规划

264. 丑数||

丑数 II(LeetCode)

0 条评论