Under construction

Still being built. Things may change

Graph Matching

Time limit1sMemory limit128 MB

Summary
Count the number of matchings (independent edge sets) of the cycle graph C_n for each given n, likely requiring big-integer arithmetic via a Lucas-sequence style recurrence.
Level

Medium5 of 10

Topics
Dynamic programming, Math, Combinatorics
Solved
No attempts yet

Problem

In graph theory, a matching (or independent edge set) is a set of edges no two of which share a common vertex.

Given a graph G=(V,E)G = (V, E), a set MM is a matching of GG if M⊆EM \subseteq E and no two edges in MM share a vertex. The empty set also counts as a matching.

The cycle graph CnC_n (n≥3n \ge 3) is a simple undirected graph with vertex set {1,2,…,n}\{1, 2, \dots, n\} and edge set E(Cn)={{a,b}∣a−b≡±1(modn)}E(C_n) = \{\{a, b\} \mid a - b \equiv \pm 1 \pmod n\}. In other words, its nn vertices are joined into a single ring by connecting neighboring vertices; it is a 22-regular graph with exactly nn edges.

Write a program that computes the number of matchings of the cycle graph CnC_n.

Input

The input consists of several test cases. Each test case is a single integer nn, given one per line, until the end of the input. (3≤n≤100003 \le n \le 10000)

Output

For each test case, print the number of matchings of CnC_n, one per line.

Examples4

  1. Example 1

    Input
    3
    4
    100
    
    Expected output
    4
    7
    792070839848372253127
    
  2. Example 2

    Input
    3
    
    Expected output
    4
    
  3. Example 3

    Input
    4
    
    Expected output
    7
    
  4. Example 4

    Input
    3
    4
    5
    6
    7
    8
    
    Expected output
    4
    7
    11
    18
    29
    47