B. Flowers for Jill

0

0 votes
Arrays, Medium
Problem

Jack has a magical plant with i initial buds. On each day each bud splits into two new buds. On every third day, x buds convert into a single flower. On day d  Jill goes to buy flowers from Jack. Tell Jill how many maximum flowers can she buy on that day. 

Remember, each flower blooms just for one day. That is, the day after the flower blooms, it withers back into a bud.

 

INPUT

A single line containing three space-separated positive integers i , x and d

 

OUTPUT

On the first line, print the maximum flowers she can buy.

On the next line, print the number of buds left on the plant.

CONSTRAINTS

1<=i<=100

2<=x<=300

1<=d<=1000

Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

1st day, there are 2 buds.

2nd day, the buds split, there are 4 buds.

3rd day, the buds split, there are 8 buds. Therefore there is 1 flower and 3 buds.

4th day, the buds split, the flower withers into a bud, there are 7 buds. 

5th day, the buds split, there are 14 buds.

6th day, the buds split, there are 28 buds. Therefore there is 5 flower and 3 buds.

Editor Image

?