#include <iostream>
#include <cmath>
using namespace std;
int main() {
double maxMoney = 0;
double temp;
int a1, b1, c1, d1, e1;
for (int a = 0; a <= 2; a++) {
for (int b = 0; b <= (20-8*a)/5; b++) {
for (int c = 0; c <= (20-8*a-5*b)/3; c++) {
for (int d = 0; d <= (20-8*a-5*b-3*c)/2; d++) {
int e = 20-8*a-5*b-3*c-2*d;
temp = 2000*pow(1+0.0084*12*8, a)*pow(1+0.0075*12*5, b)*pow(1+0.0069*12*3, c)*pow(1+0.0066*12*2, d)*pow(1+0.0063*12*1, e);
if (maxMoney < temp) {
maxMoney = temp;
a1 = a;
b1 = b;
c1 = c;
d1 = d;
e1 = e;
}
}
}
}
}
cout << a1 << " " << b1 << " " << c1 << " " << d1 << " " << e1 << endl;
cout << maxMoney << endl;
return 0;
}