PROBLEM LINK:Author: Chandan Boruah DIFFICULTY:SIMPLE PREREQUISITES:Dynamic Programming, PROBLEM:Given a word without contiguous vowels, you have to print the count of ways to write the word by repeating the vowels in the positions. The count of vowels to be repeated would be given. QUICK EXPLANATION:You can calculate for each vowel the count of ways to write them and multiply each. The count of each vowel can be calculated using dp wherein you have slots and count of the current vowel as states, adding every time a new way is found. EXPLANATION:Given a word without contiguous vowels, you have to print the ways in which you can print the word repeating the vowels contiguously, so that all vowels given are used up, except those not present in the word. Now, you can count the ways to use a then e then i then o then u whichever is present and multiply the result in each case which would be the answer. How would you calculate the ways to use each vowel. A possible solution is doing a dp and taking two states, one of how many slots or positions within consonants is there and how many total vowels are there. Then have a counter and add to the counter using up available vowels using a for loop. Refer code below
AUTHOR'S AND TESTER'S SOLUTIONS:Author's solution can be found above. Tester's solution can be found above. asked 30 Mar '16, 16:18

Here's a much simpler solution . :) Think of it like this  You have M balls and you have to distribute them into n boxes such that each box gets atleast one ball. What is the number of ways you can do this ? After a bit of thinking you will come up with an answer as C(M1,N1). (Here C(a,b) represents number of Combinations of a items taken b at a time.) Example 5 2 1 2 1 babababa Now relate this problem with the above Contest Problem . So in the string G (in the example provided above) you have 4 places where there is 'a' and you have 5 'a' in your hand to distribute them . Thus 5 'a' has to be distributed among 4 places such that each place has atleast 1 'a' . In how many ways can you do this ? C(51,41) = C(4,3) Similarly find for e,i,o,u and take their product . Remember to Keep the Mod. Edge But what if you have M balls and no places to keep it ... for this nothing is to be multiplied with the product. i.e. you dont need to find C(M1,0) coz it will be 1 If the number of places is 1 and the number of balls is also 1 ? in this case also you dont need to find the number of combinations as it will be 1 only . i.e. C(1,1)=1 So you only need to C(a,b) for this whose a>=1 && b>=2 . (This has been done to reduce the number of computations). Here is My solution  https://www.codechef.com/viewsolution/15142052 If you like my Solution, Give a THUMBS UP. answered 27 Aug '17, 20:15
nice man! I don't have enough reputation to upvote, though I would like to :)
(20 Sep '17, 09:38)
Good alternate solution :p
(25 Mar, 17:10)
