eolymp
bolt
Try our new interface for solving problems
Məsələlər

Ship Routes

Ship Routes

A Romanian tourist went on a trip to the Mediterranean Sea. He arrived to one of the cities of the \textbf{3} islands he is going to visit. Every island has exactly \textbf{N} cities and they are all ports. The tourist plans to begin his journey from the city he is in, visit all the other \textbf{3*N-1}cities exactly once and then return to the starting city so he may go back home after that. Unfortunately, there are cannibals along the roads on all the \textbf{3} islands. That's why travelling on the road between \textbf{2}cities on the same island is very dangerous and, consequently, prohibited. Hopefully, there are always ship routes. Every pair of cities which are not on the same island is connected by such a ship route. There are no routes between cities which are on the same island. The tourist wants to know in how many ways he can plan his journey through the \textbf{3} islands. \InputFile The input contains a single number: \textbf{N} (\textbf{1} ≤ \textbf{N} ≤ \textbf{30}), the number of cities on each of the \textbf{3} islands. \OutputFile You should output a single number: the number of ways the tourist can plan his trip. Note that \textbf{2} trips are identical if the successions of the \textbf{3*N} cities are identical or if the succession of the \textbf{3*N} cities of the first trip is the same as the succession of the \textbf{3*N} cities of the \textbf{2}nd trip, read backwards (for instance, if every island had \textbf{1} city, numbered according to the island's number, the trips \textbf{1-2-3-1} and \textbf{1-3-2-1} would be identical).
Zaman məhdudiyyəti 1 saniyə
Yaddaşı istafadə məhdudiyyəti 16 MiB
Giriş verilənləri #1
2
Çıxış verilənləri #1
16
Müəllif Mugurel Ionut Andreica
Mənbə Romanian Open Contest, December 2001