10541 - 拉丁正方形

一种正方形的数字编排 1 2 3 4 5 2 1 4 5 3 3 4 5 1 2 4 5 2 3 1 5 3 1 2 4 是一个55的拉丁正方形,每个1到5的整数在每行每列都出现且出现一次。 写个程序计算NN的的拉丁正方形的总数且要求第一行是: 1 2 3 4 5.......N 你的程序应该算称呼任意的从2到7的N(Your program should work for any N from 2 to 7)

输入

一行包含一个整数N

输出

只有一行没,表示拉丁正方形的个数,且拉丁正方形的第一行为 1 2 3 . . . N.

样例

输入

5

输出

1344

提示

All Latin Squares

A square arrangement of numbers

1 2 3 4 5 2 1 4 5 3 3 4 5 1 2 4 5 2 3 1 5 3 1 2 4

is a 5 x 5 Latin Square because each whole number from 1 to 5 appears once and only once in each row and column. Write a program that will compute the number of NxN Latin Squares whose first row is:

1 2 3 4 5.......N

Your program should work for any N from 2 to 7. PROGRAM NAME: latin INPUT FORMAT One line containing the integer N. SAMPLE INPUT (file latin.in) 5

OUTPUT FORMAT A single integer telling the number of latin squares whose first row is 1 2 3 . . . N. SAMPLE OUTPUT (file latin.out) 1344

时间限制 1 秒
内存限制 128 MB
统计
上一题 下一题