#include <iostream>
#include <cmath>
using namespace std;
int main(void)
{
int a1,a2,a3,a4,a5,n1,n2,n3,n4,n5;
float maxm=0,tem;
for (a5=0;a5<3;a5++)
for(a4=0;a4<(20-a5*8)/5;a4++)
for(a3=0;a3<(20-a5*8-a4*5)/3;a3++)
for(a2=0;a2<(20-a5*8-a4*5-a3*3)/2;a2++)
{
a1=20-a5*8-a4*5-a3*3-a2*2;
tem=2000*pow((double)(1+0.0084*12),(double)(a5*8))*pow((double)(1+0.0075*12),(double)(a4*5))*pow((double)(1+0.0069*12),(double)(a3*3))*pow((double)(1+0.0066*12),(double)(a2*2))*pow((double)(1+0.0063*12),(double)(a1));
if (tem>maxm)
{
maxm=tem;
n1=a1;
n2=a2;
n3=a3;
n4=a4;
n5=a5;
}
}
cout<<"存钱最大20年后为:"<<maxm<<endl;
cout<<"存钱方案如下:"<<endl;
cout<<"存1年限的次数为:"<<n1<<endl;
cout<<"存2年限的次数为:"<<n2<<endl;
cout<<"存3年限的次数为:"<<n3<<endl;
cout<<"存5年限的次数为:"<<n4<<endl;
cout<<"存8年限的次数为:"<<n5<<endl;
return 0;
}