13690 - Bad Fibonacci's soup   

Description

Fibonacci's soup is one of the most well-known recipe in Fibonacci's hometown. Besides making soup, Fibonacci also enjoys seeking weird sequences. 

We all know that we would not like to add two days before yesterday's soup into Fibonacci's soup, otherwise, It would cause food safety issues, and it would become "Bad Fibonacci's soup", aka "BFS".

One day, Fibonacci found a new sequence again. Since Fibonacci just eat Bad Fibonacci's soup for his lunch and was vomiting, he decided to name this newly found sequence "Bad Fibonacci's sequence".

 

The following is the formula for the sequence:

 

Hint:

If your program gets a "Time Limit Exceeded", your program may solve a same problem (e.g., f(m) or g(n)) too many times. We suggest that you use the dynamic programming method as follows:

  • Use a global array to store the solutions to the problems that have been solved so far.
  • Then, whenever we attempt to solve a problem, we first check the array to see if the problem is already solved.
    • ​If a solution has been recorded, we can use it directly (that is, no further recursive calls).
    • Otherwise, we solve the problem and record its solution in the array.

In this way, we can avoid repeated computation and reduce the computation time significantly.

Input

The input contains one line: nonnegative integers abcand n.  

Testcase constraints

  • For all the testcases: abc≤ 100
  • Testcase 1~3: ≤ 40
  • Testcase 4~7: ≤ 60
  • Testcase 8~10: ≤ 80
 

Output

Output one line, including f(n) and g(n).

Please remember to print '\n' at the end.

Sample Input  Download

Sample Output  Download

Tags




Discuss