Dhaka Regional ACM ICPC 2016 Preleminary Contest Solution I - Gadgets of Tomishu
I. Gadgets of Tomishu Score: 1 CPU: 1s Memory: 1200MB Little Tomishu likes numbers. But he likes electronic gadgets (mobile, tablet, phablet, laptop and so on) more than numbers. His parents are trying to keep him engaged with numbers. So, they asked him to write down all the numbers of n length, consisting of only 0 and 1, and without any neighboring 1s. For example, if n = 3, he is supposed to write: 000, 001, 010, 100 and 101. Of course, Tomishu will write the numbers in increasing order. For each of the numbers, his parent will reward him with one of the k types of gadgets. Find out the number of ways he can get the gadgets. Two ways will be different if he received different gadget for the ith number for some i. For example, for n = 3, if there are k = 2 types of gadgets (say mobile and laptop), he can get the gadgets in 2 * 2 * 2 * 2 * 2 = 2 5 = 32 ways. Since the answer can be quite big for the given n and k , you will also be given M . You...