你会存钱吗?

#include <iostream>
#include <math.h>
using namespace std;

int main() {
    int a, b, c, d, e;
    int a1, b1, c1, d1, e1;
    double temp;
    double maxMoney = 0;
    for (a = 0; a <= 2; a++) {
        temp = 0;
        for (b = 0; b <= (20-a*8); b++) {
            for (c = 0; c <= (20-a*8-b*5); c++) {
                for (d = 0; d <= (20-a*8-b*5-c*3); d++) {
                    e = 20-a*8-b*5-c*3-d*2;
                    temp = 2000*pow(1+1*0.0084*12*8, a)*pow(1+1*0.0075*12*5, b)*pow(1+1*0.0069*12*3, c)*pow(1+1*0.0066*12*2, d)*pow(1+1*0.0063*12*1, e);
                    if (temp > maxMoney) {
                        maxMoney = temp;
                        a1 = a;
                        b1 = b;
                        c1 = c;
                        d1 = d;
                        e1 = e;
                    }
                }
            }
        }

    }
    cout << a1 << " " << b1 << " " << c1 << " " << d1 << " " << e1 << endl;
    cout << maxMoney << endl;
    return 0;
}

 

相关文章:

  • 2021-07-08
  • 2020-02-22
  • 2021-11-07
  • 2021-06-02
  • 2022-01-07
  • 2021-04-16
  • 2021-11-18
  • 2022-12-23
猜你喜欢
  • 2022-01-27
  • 2021-04-10
  • 2021-07-21
  • 2021-09-26
  • 2021-07-04
  • 2021-10-02
相关资源
相似解决方案