First off, between every two occurrences of consonants there must be at least two vowels for it to be Alice’s Recipe. Having said that…

This was a really annoying problem, I managed to solve it after quite a few tries. Following lessons were learnt (by me, and they were valuable):

- Boost library is really nice.
- Don’t forget middle school lessons on how to simplify vulgar fraction. Remove their GCD.
- Don’t forget link between GCD and Prime Factors.
- Remember that log function, although inaccurate, is really efficient.

The problem involved doing a lot of multiplications and divisions while maintaining accuracy.

Here is what I did:

- Prime factorized all numbers concerned. Stored Prime factors as a map. For example 648 can be written as 2^4*3^3. Map format {2:4, 3:3}
- Implemented multiplications, divisions and raising to power by manipulating these maps. Raising to power 10 means multiplying all keys by 10. Dividing is subtracting keys. Adding means adding key.
- The final solution will be a map with a series of +ve and -ve keys. This will constitute numerator and denominator of final answer.
- Generate a vector of long long numbers to store all elements of numerator and same for denominator.
- Use log to check whether the fraction generated is greater than 10^8 or less than 10^-8. If so, just output Infinity or zero.
- Else use boost library to print the actual answer.

Solution here:: https://www.codechef.com/viewsolution/27850010