#include #include using namespace std; const int MAXINT=2147483647; const int SIZE=1000000; int c[SIZE+1]; void change(int sum) { //set up initial values, where c[sum]=(number of coins) c[0]=0; c[1]=1; c[2]=2; c[3]=3; c[4]=4; c[5]=5; c[6]=6; c[7]=1; c[8]=2; c[9]=3; c[10]=4; c[11]=5; c[12]=1; //compute the rest - minimize number of coins for (int cost=13;cost<=sum;cost++) c[cost]=1+min(min(c[cost-1],c[cost-7]),c[cost-12]); //min(a,b,c) = min[min(a,b),c] } int main() { change(1000000); //precompute values up to the largest test case int n; string rs,cs; //"s" ending for rupees and coins while (cin>>n && n!=0) { if (n==1) rs="";else rs="s"; if (c[n]==1) cs="";else cs="s"; cout<<"The bill of "<0 you are pretty much all set. If you are lost, think of computing Fibonacci sequences (That is what got me over the edge!) If you are still lost, consult dennismv, your favorite prof, or take CIS 405 */