#include unsigned int total[2][4]; unsigned int count[2][4]; unsigned int price[4] = { 1, 5, 10, 50}; unsigned int x, xx; unsigned int out[2][4]; unsigned int s1, s2; unsigned int solve (int z) { int i; total[z][0] = count[z][0]; total[z][1] = total[z][0] + 5 * count[z][1]; total[z][2] = total[z][1] + 10 * count[z][2]; total[z][3] = total[z][2] + 25 * count[z][3]; for (i = 3; i > 0; i--) { if (x >= total[z][i - 1]) { unsigned m; m = (x - total[z][i - 1] + price[i] - 1) / price[i]; x -= price[i] * m; out[z][i] += m; if (i==3) out[z][i] += m; } } out[z][0] += x; if (x > count[z][0]) return 0; return out[z][0] + out[z][1] + out[z][2] + out[z][3]; } int main() { int i; while (1) { int z = 0; scanf ("%u%u%u%u%u", &xx, &count[z][0], &count[z][1], &count[z][2], &count[z][3]); if (xx == 0) return 0; for (i = 0; i < 4; i++) { count[1][i] = count[0][i]; out[0][i] = out[1][i] = 0; } x = xx; count[0][3] /= 2; s1 = solve(0); if (count[1][3] > 0 && xx >= 25) { out[1][3] = 1; count[1][3]--; x = xx - 25; } else x = xx; count[0][3] /= 2; s2 = solve(1); if (s1 == 0 && s2 == 0) { printf ("Charlie cannot buy coffee.\n"); } else { if (s1 < s2) z = 1; else z = 0; printf ("Throw in %u cents, %u nickels, %u dimes, and %u quarters.\n", out[z][0], out[z][1], out[z][2], out[z][3]); } } }