Graph Matching
Time limit1sMemory limit128 MB
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 , a set is a matching of if and no two edges in share a vertex. The empty set also counts as a matching.
The cycle graph () is a simple undirected graph with vertex set and edge set . In other words, its vertices are joined into a single ring by connecting neighboring vertices; it is a -regular graph with exactly edges.
Write a program that computes the number of matchings of the cycle graph .
Input
The input consists of several test cases. Each test case is a single integer , given one per line, until the end of the input. ()
Output
For each test case, print the number of matchings of , one per line.