All submissions for this problem are available.
Baloo and Mowgli
Both got bored of their games and decided to find a new game. Both are at start (0) initially. Shanti being Mowgli’s girlfriend has an upper hand and decides to make them play to her tunes.
She speaks out 2 numbers k1 and k2 for baloo and c1 and c2 for Mowgli. Baloo can jump from his position k1 units ahead or k2 units ahead. Mowgli being someone special enjoys the privilege of either jumping from his position c1 units ahead or c2 units ahead.Mowgli can also change his moves(c1 and c2) with the moves of Baloo (k1 and k2) at each step once in the game and then he wont be able to use his moves (c1 and c2) again.Find the number of ways that Mowgli can jump to a given distance considering all the possible moves.Since the output can be really large , print it modulo 10^9+7
The First line consist of T – No of testcases, followed by 4 lines of each testcase. The 1st line gives the value of N (Distance to be moved).The 2nd line gives c1 and c2 of Mowgli.The 3rd line gives k1 and k2 for Baloo.
Print T lines each having a number M modulo 10^9+7 giving the total ways of reaching postion N
Input: 1 5 1 2 2 3 Output: 16
|Time Limit:||3 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP 4.3.2, CPP 6.3, CPP14, GO, JAVA, NODEJS|
Fetching successful submissions
If you are still having problems, see a sample solution here.