3. Number of Words
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

The alphabet of a certain language consists only of three letters — 'a', 'o', and 'c'. Determine the maximum number of words of length N that can exist in the language if each letter of the alphabet can occur in a word no more than K times. For example, for N=2 and K=1 the answer is 6 (these are the words 'ao', 'oa', 'oc', 'co', 'ac', and 'ca'). For N=2 and K=2 the answer is 9, as the words 'aa', 'oo', 'cc' are added. Find the answers for the following pairs of values N and K:

  • N=3, K=1
  • N=3, K=3
  • N=4, K=3
  • N=20, K=10

To submit a solution in the Codeforces system, click the "Submit code" link (above the problem statement). In the "Source code" field, write four integers separated by spaces, without writing anything extra. In the "Language" field, select PHP.

Scoring

Each correct answer is worth 25 points. The participant is informed of the total points scored.

During the Olympiad, participants had 10 attempts to submit a solution. There is no such restriction on Codeforces.