Submit Status
Description
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.
Sample Input
Input 5 Output 120Source
Experimental Educational Round: VolBIT Formulas Blitz //题意: 有n条东西向的路,有n条南北向的路,并且东西向的每条路都与南北向的每条路相交,也就形成了n*n个十字路口,现在要在这么多个路口放5条长椅,并且每条路上最多能放一条长椅,问有多少种放法。 //思路sum=A(5,5)*C(n,5)*C(5,5)。 #include<stdio.h>#include<string.h>#include<algorithm>#define INF 0x3f3f3f3f#define ll long long#define N 10010#define M 1000000007using namespace std;ll C(int n,int x){int i,j;ll s=1;for(i=n,j=1;i>n-x;i--,j++)s*=i,s/=j;return s;}int main(){int i,n;while(scanf("%d",&n)!=EOF){ll sum=120*C(n,5)*C(n,5);printf("%lldn",sum);}return 0;}