Using JAVA solve the below problem Amitabh had a magical cat. That cat once fell down an empty well. As the walls of the well were not completely vertical, the cat could climb up the well. In one day, the cat can climb 1 unit height and the height of the well is h units. The cat starts at the bottom. Every day, a cat would divide into 2 cats. One of them would climb up 1 unit. The other would wait for help. But while waiting it would fall asleep and roll down 1 unit, unless it is already at the bottom, in which case it just remains there. When a cat would reach the top, it would run home toAmitabh. (Schrodinger doesn't know that some of the cats are in a well and so he can't rescue them).
Using JAVA solve the below problem
Amitabh had a magical cat. That cat once fell down an empty well. As the walls of the well were not completely vertical, the cat could climb up the well. In one day, the cat can climb 1 unit height and the height of the well is h units. The cat starts at the bottom. Every day, a cat would divide into 2 cats. One of them would climb up 1 unit. The other would wait for help. But while waiting it would fall asleep and roll down 1 unit, unless it is already at the bottom, in which case it just remains there. When a cat would reach the top, it would run home toAmitabh. (Schrodinger doesn't know that some of the cats are in a well and so he can't rescue them).
It has been d days since the cat fell into the well. How many cats would come out of the well today? You would notice that the number of cats grows very large with each passing day, so output the answer modulo 10^9+7. d = 0 means that the cat has fallen just now and so there's just one cat at the bottom of the well. So you wouldn't see any cat coming out today. If the height of the well is 1 unit, you will see a cat come out tomorrow.
Step by step
Solved in 2 steps with 1 images