The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | May 2017 |
| Last Sign in: | 406 Weeks Ago, 2 Days Ago |
| Questions Answered: | 66690 |
| Tutorials Posted: | 66688 |
MCS,PHD
Argosy University/ Phoniex University/
Nov-2005 - Oct-2011
Professor
Phoniex University
Oct-2001 - Nov-2016
The alphabet of Zorpia is quite peculiar. It consists of only two letters, A and B and that too in upper-case only. A visitor to Zorpia is amazed by the diversity of words formed by the combination of A and B. He notices one more peculiar thing about the words. All the words were of even length and the number of A’s in the word is equal to the number of B’s. One of the natives told him that it is the number of transitions in the word that guides the pronunciation of the words. The words having same number of transitions are pronounced almost similarly.
Â
Let us define what transition means here. A transition occurs in a word whenever there is a change from A to B. Eg: consider the word ABAB. It has three transitions. First when going from index 1 to 2, second when going from 2 to 3 and third when going from 3 to 4.
Â
Given the length of the word and the number of transitions, the visitor needs to find out how many such words are possible from the alphabet of Zorpia and following the rules for word as described above.
Â
Â
Â
The input consists of several test cases(5000 atmost). Each test case consists of two integers n and k where n is the length of word and n(2
Â
Â
For every test case output on a line an integer which is the number of words possible modulo 1,000,000,007.
Â
Input: 6 2 6 3 0 0 Output: 4 8
Â
For the first case the 4 words are AABBBA, ABBBAA, BAAABB, BBAAAB
Hel-----------lo -----------Sir-----------/Ma-----------dam-----------Tha-----------nk -----------You----------- fo-----------r u-----------sin-----------g o-----------ur -----------web-----------sit-----------e a-----------nd -----------and----------- ac-----------qui-----------sit-----------ion----------- of----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n.P-----------lea-----------se -----------pin-----------g m-----------e o-----------n c-----------hat----------- I -----------am -----------onl-----------ine----------- or----------- in-----------box----------- me----------- a -----------mes-----------sag-----------e I----------- wi-----------ll