#include int price; int c1, c5, c10, c25; int t1, t5, t10, t25; void spotrebuj_vsechny_c25(){ while (price>=25 && c25){c25--; price-=25; t25++; } } void spotrebuj_vsechny_c10(){ while (price>=10 && c10){c10--; price-=10; t10++; } } void spotrebuj_vsechny_c5(){ while (price>=5 && c5){c5--; price-=5; t5++; } } void spotrebuj_vsechny_c1(){ while (price>=1 && c1){c1--; price-=1; t1++; } } int sum1(){ return c1; } int sum2(){ return 5*c5+c1; } int sum3(){ return 10*c10+5*c5+c1; } void zamen_t5(){ price=5; t5 --; c5 ++; spotrebuj_vsechny_c1 (); } void zamen_t10(){ price=10; t10 --; c10 ++; spotrebuj_vsechny_c5 (); spotrebuj_vsechny_c1 (); } void zamen_t25(){ price=25; t25 --; c25 ++; spotrebuj_vsechny_c10 (); spotrebuj_vsechny_c5 (); spotrebuj_vsechny_c1 (); } int main(){ while (1){ scanf ("%d %d %d %d %d", &price, &c1, &c5, &c10, &c25); t1=t5=t10=t25=0; // printf("a1\n"); if (!(price | c1 | c5 | c10 | c25)) return 0; // printf("a2\n"); spotrebuj_vsechny_c25(); spotrebuj_vsechny_c10(); spotrebuj_vsechny_c5(); spotrebuj_vsechny_c1(); // printf("a3\n"); if (price) { printf("Charlie cannot buy coffee.\n"); continue; } // printf("a4\n"); while (t25 && sum3()>=25) zamen_t25(); while (t10 && sum2()>=10) zamen_t10(); while (t5 && sum1()>=5) zamen_t5(); printf("Throw in %d cents, %d nickels, %d dimes, and %d quarters.\n", t1, t5, t10, t25); } return 0; }