Parin
BAN USERSo, here I go.
base cases : countWays(1)=1; countWays(2)=2;countWays(3)=2;countWays(4)=3;countWays(5)=3
Calculate Maximum number of 1,2,5,10 bills that can be used in amount x.
ONES = x; TWOS = x/2; FIVES = x/5; TENS = x/10;
So, number of ways are following. ways = 0;
1. All 1$ bills used. ways+=1;
2. All 2$ bills are used (even amount) or All 2$ and one 1$ bill used (odd amount). ways+=1;
3. (TWOS-1) can be replaced with two 1$ bill. ways+=(TWOS-1)
4. All 5$ bills possible are used and calculate ways of remainder. So, ways+=countWays(n%FIVES).
5. (FIVES-1) bills replaced by 2,2,1$ bills. So, ways+=(FIVES-1)*countWays(n%FIVES)
6. All 10% bills possible are used and calculate ways of remainder. ways+=countWays(n%TENS).
7. (TENS-1) bills replaced by 5,5$ bills. So, ways+=(TENS-1)*ways(n%TENS)
So, here I go.
base cases : countWays(1)=1; countWays(2)=2;countWays(3)=2;countWays(4)=3;countWays(5)=3
Calculate Maximum number of 1,2,5,10 bills that can be used in amount x.
ONES = x; TWOS = x/2; FIVES = x/5; TENS = x/10;
So, number of ways are following. ways = 0;
1. All 1$ bills used. ways+=1;
2. All 2$ bills are used (even amount) or All 2$ and one 1$ bill used (odd amount). ways+=1;
3. (TWOS-1) can be replaced with two 1$ bill. ways+=(TWOS-1)
4. All 5$ bills possible are used and calculate ways of remainder. So, ways+=countWays(n%FIVES).
5. (FIVES-1) bills replaced by 2,2,1$ bills. So, ways+=(FIVES-1)*countWays(n%FIVES)
6. All 10% bills possible are used and calculate ways of remainder. ways+=countWays(n%TENS).
7. (TENS-1) bills replaced by 5,5$ bills. So, ways+=(TENS-1)*ways(n%TENS)
building class with properties like Street address, # of total properties in the building, parking space, No. of parking places available to rent, etc..Child classes derived from building classes like Apartment, Store, Office, etc.. Each one having Suite no, monthly maintenance cost and a constructor which checks with total # of properties available in apartment before creating instance of property. Apartment class has properties like # of bedrooms. When each time constructor is called to reserve a new property in the building,
- Parin September 02, 2013