Legible Words X65131


Statement
 

pdf   zip

html

In computer science we often consider words made of letters. Usually these are arbitrary strings of letters, but in practice, not all of such words would be legible (for example, it is hard to pronounce bcabcbca).

It is hard to define whether a word is legible. In this problem, we assume that a word is legible iff there are no three consecutive consonants.

Your task is to calculate the number of legible words of given length, using the given letters.

Input

Input consists of several cases. Each case consists of three numbers: C (the number of considered consonants), V (the number of considered vowels), N (the length of the words to consider). We have 1 ≤ C ≤ 50, 1 ≤ V ≤ 50, 1 ≤ N ≤ 100.

After the last case the input contains a line containing 0 0 0.

Output

Output the number of legible words. It is guaranteed that it will never be greater than 1018.

We have three consonants and two wovels, say, a, b, c, d, e. According to our definition, there are 5 words of length 1 (all letters), and 25 words of length 2 (all possible pairs of letters). At length 3 the answer is 98 (out of 53 possible words, 33 consists of only wovels, which makes them illegible).

Public test cases
  • Input

    3 2 1
    3 2 2
    3 2 3
    3 2 4
    0 0 0
    

    Output

    5
    25
    98
    436
    
  • Information
    Author
    Eryk Kopczynski
    Language
    English
    Official solutions
    Unknown.
    User solutions
    C++