
#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;
}