1 #include <iostream>
2 #include <cmath>
3 using namespace std;
4 int main()
5 {
6 int x1,x2,x3,x4,x5;
7 int a,b,c,d,e;
8 double max=0.0,x;
9 for(x5=0;x5<=2;x5++)
10 {
11 for(x4=0;x4<=(20-x5*8)/5;x4++)
12 {
13 for(x3=0;x3<=(20-x5*8-x4*5)/3;x3++)
14 {
15 for(x2=0;x2<=(20-x5*8-x4*5-x3*3)/2;x2++)
16 {
17 x1=20-8*x5-x4*5-x3*3-x2*2;
18 x=2000.0*pow((1+0.0063*12),x1)
19 *pow((1+0.0066*2*12),x2)
20 *pow((1+0.0069*3*12),x3)
21 *pow((1+0.0075*5*12),x4)
22 *pow((1+0.0084*8*12),x5);
23 if(x>max)
24 {
25 max=x;
26 a=x1;
27 b=x2;
28 c=x3;
29 d=x4;
30 e=x5;
31 }
32 }
33 }
34 }
35 }
36 cout<<max<<endl;
37 cout<<"存一年几次:"<<a<<endl;
38 cout<<"存二年几次:"<<b<<endl;
39 cout<<"存三年几次:"<<c<<endl;
40 cout<<"存五年几次:"<<d<<endl;
41 cout<<"存八年几次:"<<e<<endl;
42
43 }