package main import "fmt" func main() { var a, b, n int var xn2, xn1, xn int xn1 = 1 mod := int(1e9) + 7 fmt.Scan(&a, &b, &n) if n == 0 { fmt.Println(0) } else if n == 1 { fmt.Println(1) } else { for i := 0; i < n-1; i++ { xn = ((a%mod)*(xn1%mod) + (b%mod)*(xn2%mod)) % mod // fmt.Printf("i %d, xn %d, xn1 %d, xn2 %d\n", i, xn, xn1, xn2) xn2 = xn1 xn1 = xn } fmt.Println(xn) } }