package main import ( "fmt" "log" ) type int uint // yukicoder 526 // 最小二乗法 var M int func main() { log.SetFlags(log.Lshortfile) M = 1000000007 var N int fmt.Scan(&N) fmt.Println(fib(fib(N)) % M) } func fib(n int) int { if n == 0 { return 0 } var A [2][2]int A[0][0] = 1 A[0][1] = 1 A[1][0] = 1 A[1][1] = 0 var B [2][2]int for i := range B { B[i][i] = 1 } // log.Println(A, B) for n > 0 { if n&1 == 1 { B = mul(B, A) } A = mul(A, A) n >>= 1 } // log.Println(A[1][1], B) // log.Println(B[1][0] % M) return B[1][0] % M } func mul(a, b [2][2]int) [2][2]int { var c [2][2]int for i := 0; i < len(a); i++ { for k := 0; k < len(b); k++ { for j := 0; j < len(b[0]); j++ { c[i][j] = (c[i][j] + a[i][k]*b[k][j]) % M } } } return c }