H. Benches
time limit per test
0.5 seconds
memory limit per test
64 megabytes
input
standard input
output
standard output
The city park of IT City contains n east to west paths and n north to south paths. Each east to west path crosses each north to south path, so there are n2 intersections.
The city funded purchase of five benches. To make it seems that there are many benches it was decided to place them on as many paths as possible. Obviously this requirement is satisfied by the following scheme: each bench is placed on a cross of paths and each path contains not more than one bench.
Help the park administration count the number of ways to place the benches.
Input
The only line of the input contains one integer n (5 ≤ n ≤ 100) — the number of east to west paths and north to south paths.
Output
Output one integer — the number of ways to place the benches.
Examples
Input
5
Output
120
主要是讲有N*N个位置,问要房5个板凳,且不同行不同列,问有多少方法,注意组合数计算会超longlong。
#include<stdio.h>
#include<string.h>
#include<algorithm>
#define LL __int64
using namespace std;
int n;
__int64 C(int x)
{
LL oo=1;
int i,j=0;
int yy=1;
for(i=5;i>=1;i--)
{
oo=oo*(x-j);
oo/=yy;
x--;
yy++;
}
return oo;
}
int main()
{
while(scanf("%d",&n)!=EOF)
{
LL a,b;
a=C(n);
b=a*a*120;
printf("%I64d\n",b);
}
return 0;
}