#include<iostream>
#include<math.h>
using namespace std;
int main(){
int x1,x2,x3,x5,x8,b[10];
double a,max=0.0;
for(x8=0;x8<=2;x8++){//穷举法找到符合条件的结果从其中一个进行将下一个进行20减去前一个的年数
for(x5=0;x5<=(20-8*x8)/5;x5++){
for(x3=0;x3<=(20-8*x8-5*x5)/3;x3++){
for(x2=0;x2<=(20-8*x8-5*x5-3*x3)/2;x2++){
x1=20-8*x8-5*x5-3*x3-2*x2;
a=2000.0*pow((1+0.0063*12),x1)*pow((1+0.0066*12*2),x2)*pow((1+0.0069*12*3),x3)//pow函数后面括号里为(x,y)意为x的y次方同时必须含有函数的头文件#include<math.h>;
*pow((1+0.0075*12*5),x5)*pow((1+0.0084*12*8),x8);
if(a>max){
max=a;
b[0]=x1;
b[1]=x2;
b[2]=x3;
b[3]=x5;
b[4]=x8;
}
}
}
}
}
cout<<a<<endl;
cout<<b[0]<<" "<<b[1]<<" "<<b[2]<<" "<<b[3]<<" "<<b[4]<<endl;
}
标签:11,12,pow,x8,x2,x3,x5 From: https://www.cnblogs.com/guozi6/p/17357359.html