eolymp
bolt
Спробуйте наш новий інтерфейс для відправки розв'язків
Задачі

Edge Case

Edge Case

\includegraphics{https://static.e-olymp.com/content/6e/6ef42d78bffdcbe0ef4771493c2fc270c9499474.jpg} In graph theory, a \textit{matching or independent edge set} in a graph \textbf{G = (V, E)} is a set of edges \textbf{ME} such that no two edges in the matching \textbf{M} share a common vertex. Recently you saw in the news that "The Sveriges Riksbank Prize in Economic Sciences in Memory of Alfred Nobel" (informally, the Nobel Prize in Economics) for \textbf{2012} was awarded to Alvin E. Roth and Lloyd S. Shapley for, amongst other things, their algorithm for finding a matching satisfying certain criteria in a bipartite graph. Since you have also heard that matchings in \textit{cycle graphs} have applications in chemistry your thoughts centre around a plan for a beautiful future where your Christmas shopping is more luxurious than ever! The cycle graph, \textbf{C_n}, \textbf{n} ≥ \textbf{3}, is a simple undirected graph, on vertex set \{\textbf{1}, ..., \textbf{n}\}, with edge set \textbf{E(Cn) = \{(a, b\} | |a-b|≡1 mod n\}}. It is \textbf{2}-regular, and contains \textbf{n} edges. The graphs \textbf{C_3}, \textbf{C_4}, \textbf{C_5}, and \textbf{C_6} are depicted in \textit{\textbf{Figure 1}}. \includegraphics{https://static.e-olymp.com/content/71/7125d88d4e8bd831b086934ace7db85dfec12fd1.jpg} \textit{\textbf{Figure 1}}: The graphs \textbf{C_3}, \textbf{C_4}, \textbf{C_5}, and \textbf{C_6}. Your first step towards Nobel Prize fame is to be able to compute the number of matchings in the cycle graph \textbf{C_n}. In \textit{\textbf{Figure 2}} the seven matchings of the graph \textbf{C_4} are depicted. \includegraphics{https://static.e-olymp.com/content/3d/3d2fcf672843bfb26a0740104d304855fda444aa.jpg} \textit{\textbf{Figure 2}}: The matchings of \textbf{C_4}. The edges that are part of the respective matching are coloured green, while the edges left out of the matching are dashed. \textbf{M_1 = Ø}, \textbf{M_2 = \{\{2, 1\}\}}, \textbf{M_3 = \{\{3, 2\}\}}, \textbf{M_4 = \{\{4, 3\}\}}, \textbf{M_5 = \{\{1, 4\}\}}, \textbf{M_6 = \{\{2, 1\},\{4, 3\}\}}, and \textbf{M_7 = \{\{3, 2\},\{1, 4\}\}}. \InputFile For each test case, you get a single line containing one positive integer: \textbf{n}, with \textbf{3} ≤ \textbf{n} ≤ \textbf{10000}. \OutputFile For each test case, a row containing the number of matchings in \textbf{C_n}.
Ліміт часу 1 секунда
Ліміт використання пам'яті 64 MiB
Вхідні дані #1
3
4
100
Вихідні дані #1
4
7
792070839848372253127
Джерело NWERC 2012 - NorthWestern European Regional Championship 2012