Registrations for the November 2021 System Design Cohort are now open Enroll Today


#  Author: Arpit Bhayani

x = raw_input().split()

dp = {}

def fib(t1, t2, n):
    if n == 1:
        return t1

    if n == 2:
        return t2

    t3 = dp.get(n)
    if t3 is None:
        t3 = fib(t1, t2, n-2) + fib(t1, t2, n-1) ** 2
        dp[n] = t3

    return t3

print fib(int(x[0]), int(x[1]), int(x[2]))

470+ Competitive Programming Solutions

If you like what you read subscribe to my newsletter.

I write essays on various engineering topics and share it through my weekly newsletter 👇