Codeforces 630H Benches
来源:互联网 发布:大数据涉及技术要求 编辑:程序博客网 时间:2024/04/29 13:13
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.
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 one integer — the number of ways to place the benches.
5
120
n条从北向南的路和n条从东向西的路,共n^2个交点,共5把椅子,放在交点,然后每条路上最多只能有一把椅子
求放椅子的方法数 方法比较笨,每次循环放一把椅子
#include <iostream>#include<cstdio>#include<cstring>#include<cmath>#define maxn 110using namespace std;int main(){ int n; long long sum; while(~scanf("%d",&n)) { sum=1; int flag1=0,flag2=0,flag3=0,flag4=0; for(int i=0;i<5;++i) { sum*=(n-i)*(n-i); if(!flag1&&sum%2==0) { flag1=1; sum=sum/2; } if(!flag2&&sum%3==0) { flag2=1; sum=sum/3; } if(!flag3&&sum%4==0) { flag3=1; sum=sum/4; } if(!flag4&&sum%5==0) { flag4=1; sum=sum/5; } } printf("%I64d\n",sum); } return 0;}
- Codeforces 630H Benches
- codeforces 630H. Benches
- CodeForces 630H:Benches【排列组合】
- CodeForces-630 H. Benches【排列组合】
- CodeForces-630 H. Benches【排列组合】
- CodeForces 630 H. Benches(组合数学)
- CodeForces - 630H Benches (组合数学)
- CodeForces 630H- Benches【组合数学】
- Codeforces--630H--Benches(组合数)
- CodeForces 630H- Benches【组合数学】
- Benches
- codeforces_630H. Benches
- CodeForces 245H
- CodeForces 245H
- codeforces GYM 100792H
- codeforces 589H DFS
- codeforces 549H 二分
- Benches(排列组合)
- 3.javascript函数
- 哈夫曼树
- java集合中各个接口与实现类的区别
- JAVA String 类 总结(1)
- 求数组逆序对个数
- Codeforces 630H Benches
- poj3524 Corn Fields(状态压缩dp)
- linux基础学习之 gSOAP2.8.30在linux下的安装
- TCP、UDP、IP 协议分析
- 剑指offer-面试题35:第一个只出现一次的字符
- 配置和简单运行Heritrix3.2.0(环境为win10 64)
- BSD系统全家福
- Oracle PL/SQL异常处理
- 存储过程优点