提交时间:2023-01-12 17:03:03

运行 ID: 67370

#include<bitstdc++.h> using namespace std; int k,a[11]={0},f[110]; inline int in(){ int x=0; char ch=getchar(); while (ch<'0' || ch>'9') ch=getchar(); while (ch>='0' && ch<='9') x=x*10+ch-'0',ch=getchar(); return x; } int main(){ memset(f,0x3f,sizeof(f)); for (int i=1; i<=10; i++) f[i]=in(); k=in(); for (int i=2; i<=k; i++) for (int j=1; j<i; j++) f[i]=min(f[i],f[j]+f[i-j]); for (int i=1; i<=k; i++) cout<<f[i]<<" "; cout<<endl; cin>>f[k]; return 0; }