由于只是问不能支付的最小值,所以只需要简单的用布尔值标记即可。
![ContractedBlock.gif](https://i-blog.csdnimg.cn/blog_migrate/8f900a89c6347c561fdf2122f13be562.gif)
![ExpandedBlockStart.gif](https://i-blog.csdnimg.cn/blog_migrate/961ddebeb323a10fe0623af514929fc1.gif)
1 //#include <fstream>
2 #include <iostream>
3 using namespace std;
4
5 bool money[8002];
6 int main()
7 {
8 //fstream cin("Holding Bin-Laden Captive.txt");
9 unsigned numFive,numTwo,numOne;
10 while(cin>>numOne>>numTwo>>numFive)
11 {
12 if(numOne==0&&numTwo==0&&numFive==0)
13 break;
14 memset(money,0,sizeof(bool)*(8002));
15 for(unsigned i=0;i<=numFive;i++)
16 for(unsigned j=0;j<=numTwo;j++)
17 for(unsigned k=0;k<=numOne;k++)
18 money[k+j*2+i*5]=true;
19 for(int i=1;i<=8001;i++)
20 if(money[i]==false)
21 {
22 cout<<i<<endl;
23 break;
24 }
25 }
26 return 0;
27 }