#include int price; int c1, c5, c10, c25; int t1, t5, t10, t25; int tc25, tc10, tc5, tc1; int tt25, tt10, tt5, tt1; void save(){ tc25=c25; tc10=c10; tc5=c5; tc1=c1; tt25=t25; tt10=t10; tt5=t5; tt1=t1; } void rollback(){ c25=tc25; c10=tc10; c5=tc5; c1=tc1; t25=tt25; t10=tt10; t5=tt5; t1=tt1; } 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; } int zamen_t5(){ save(); price=5; t5 --; c5 ++; spotrebuj_vsechny_c1 (); if (price){ rollback(); price=0; return 0; } return 1; } int zamen_t10(){ save(); price=10; t10 --; c10 ++; spotrebuj_vsechny_c5 (); spotrebuj_vsechny_c1 (); if (price){ rollback(); price=0; return 0; } return 1; } int zamen_t25(){ save(); price=25; t25 --; c25 ++; spotrebuj_vsechny_c10 (); spotrebuj_vsechny_c5 (); spotrebuj_vsechny_c1 (); if (price){ rollback(); price=0; return 0; } return 1; } int main(){ while (1){ scanf ("%d %d %d %d %d", &price, &c1, &c5, &c10, &c25); t1=t5=t10=t25=0; if (!(price | c1 | c5 | c10 | c25)) return 0; spotrebuj_vsechny_c25(); spotrebuj_vsechny_c10(); spotrebuj_vsechny_c5(); spotrebuj_vsechny_c1(); if (price) { printf("Charlie cannot buy coffee.\n"); continue; } 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; }