Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
Register

## Why i was always wrong ?I've checked quite a lot of test cases, but I still haven't found a wrong answer.

Posted by anonym11 at 2004-09-06 02:19:32 on Problem 1787
```My code is as follow:
#include <iostream>
using namespace std;
int c1,c2,c3,c4;
void print()
{
printf("Throw in %d cents, %d nickels, %d dimes, and %d quarters.\n",c1,c2,c3,c4);
}
int main()
{
long int price,sum,del;
cin >> price >> c1 >> c2 >> c3 >> c4;
while(price || c1 || c2 || c3 || c4)
{
sum = c1 + 5*c2 + 10*c3 + 25*c4;
price = sum - price;
if(price<0)
cout << "Charlie cannot buy coffee.\n";
else      //subtract the least coins.
{
if(!price)
{
print();
goto in;
}
else
{
del = (price/25)>c4?c4:(price/25);
c4 -= del;
price -= 25*del;
}
if(!price)
{
print();
goto in;
}
else
{
del = (price/10)>c3?c3:(price/10);
c3 -= del;
price -= 10*del;
}
if(!price)
{
print();
goto in ;
}
else
{
del = (price/5)>c2?c2:(price/5);
c2 -= del;
price -= 5*del;
}
if(!price)
{
print();
goto in;
}
else
{
del = price>c1?c1:price;
c1 -= del;
price -= del;
}
if(!price)
print();
else
cout << "Charlie cannot buy coffee.\n";
}
in:
cin >> price >> c1 >> c2 >> c3 >> c4;
}
return 0;
}
```

Followed by: