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
5
120
My solution:
/*2016.3.11*/
#include<stdio.h>
int main()
{
int i,n;
long long ans;
while(scanf("%d",&n)==1)
{
ans=1;
for(i=n;i>=n-4;i--)
ans*=i;
ans=ans/120*ans;
printf("%lld\n",ans);
}
return 0;
}

本文探讨了在城市公园中,基于给定路径数量的情况下,如何利用排列组合原理计算放置长椅的所有可能布局方案。具体而言,文章通过分析路径交叉点的配置,展示了计算长椅布局方案数的方法。
1335

被折叠的 条评论
为什么被折叠?



