题解
2023-08-31 19:28:51
发布于:广东
3阅读
0回复
0点赞
#include <iostream>
using namespace std;
bool total[1010] = {};
int a[7], b[7] = {0,1,2,3,5,10,20};
int main()
{
int i,j,k,l,m,count=0,max=0;
total[0] = 1;
for (i = 1; i < 7; i++)
{
cin >> a[i];
max += a[i] * b[i];
}
for ( j = 1; j < 7; j++)
for ( k = 1; k < a[j]+1; k++)
for ( l = max; l >= 0; l--)
{
if (total[l])
total[l + b[j]] = 1;
}
for ( m = 1; m < 1001; m++)
{
if (total[m])
count++;
}
cout << "Total=" << count;
return 0;
}
这里空空如也
有帮助,赞一个