Codeforces--630H--Benches(组合数)
Benches
Crawling in process...
Crawling failed
Time Limit:500MS
Memory Limit:65536KB 64bit IO Format:%I64d & %I64u
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
远看还以为是阶乘,--||然而n可以到一百,看了题才知道是组合数,东西向,南北向的路各n条,相互垂直的两条路一定会相交,形成了n*n个路口,现在5张长凳,
把凳子放到路口,并且每条路只能出现一张凳子,那摩我们就要从南北向,东西向的路中各挑出5条,然后,,,,,,
#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;
__int64 C(__int64 m,__int64 n)
{
__int64 ans=1;
__int64 num=1;
while(n--)
{
ans*=(m-n);
ans/=num;
num++;
}
return ans;
}
int main()
{
__int64 n;
while(cin>>n)
{
cout<<120*C(n,5)*C(n,5)<<endl;
}
return 0;
}
Codeforces--630H--Benches(组合数)的更多相关文章
- (水题)Codeforces - 630H - Benches
https://codeforces.com/problemset/problem/630/H 又一个组合数学的问题,我们先考虑在 $n$ 列中选出 $5$ 列来放椅子,然后对第一列有 $n$ 种放法 ...
- Codeforces 100548F - Color (组合数+容斥)
题目链接:http://codeforces.com/gym/100548/attachments 有n个物品 m种颜色,要求你只用k种颜色,且相邻物品的颜色不能相同,问你有多少种方案. 从m种颜色选 ...
- codeforces 630H (组合数学)
H - Benches Time Limit:500MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u Submit S ...
- Codeforces 521C (经典)组合数取模【逆元】
<题目链接> <转载于 >>> > 题目大意:给出一串n个数字,让你在这串数字中添加k个 ' + ' 号(添加后表达式合法),然后所有拆分所得的所有合法表达 ...
- codeforces 691F(组合数计算)
Couple Cover, a wildly popular luck-based game, is about to begin! Two players must work together to ...
- Educational Codeforces Round 26 F. Prefix Sums 二分,组合数
题目链接:http://codeforces.com/contest/837/problem/F 题意:如题QAQ 解法:参考题解博客:http://www.cnblogs.com/FxxL/p/72 ...
- Codeforces 893E Counting Arrays:dp + 线性筛 + 分解质因数 + 组合数结论
题目链接:http://codeforces.com/problemset/problem/893/E 题意: 共q组数据(q <= 10^5),每组数据给定x,y(x,y <= 10^6 ...
- Codeforces 869C The Intriguing Obsession:组合数 or dp
题目链接:http://codeforces.com/problemset/problem/869/C 题意: 红色.蓝色.紫色的小岛分别有a,b,c个. 你可以在两个不同的岛之间架桥,桥的长度为1. ...
- Codeforces 785 D.Anton and School - 2(组合数处理)
Codeforces 785 D.Anton and School - 2 题目大意:从一串由"(",")"组成的字符串中,找出有多少个子序列满足:序列长度为偶 ...
- Codeforces 131C . The World is a Theatre(打表组合数)
题目链接:http://codeforces.com/contest/131/problem/C 大意就是有n个男孩,m个女孩,从男孩中选不少于4个男孩,女孩中选不少于1个女孩,组成人数为t的队伍,问 ...
随机推荐
- facenet
facenet dl face recognition 一.运行facenet 验证lfw数据集效果: python2.7 src/validate_on_lfw.py ~/dataset/lfw ...
- 常用的SSH注解标签
常用的SSH注解标签 1.Spring的注解 关于配Bean用的 @Component @Controller @Service @Repository 作用 ...
- 8、scala面向对象编程之对象
1. Object 2.伴生对象 3.让object继承抽象类 4.apply方法 5.main方法 6.用object实现枚举功能 1. Object Object,相当于class的单个实例, ...
- Html test
<!DOCTYPE html> <html lang="en" xmlns="http://www.w3.org/1999/xhtml"> ...
- Apache 在Linux上的安装
1.获取源码 wget http://mirror.bit.edu.cn/apache//httpd/httpd-2.4.37.tar.gz 2.卸载centos自带的apache 3.解压apach ...
- JNI数组操作
在Java中数组分为两种: 1.基本类型数组 2.对象类型(Object[])的数组(数组中存放的是指向Java对象中的引用) 一个能通用于两种不同类型数组的函数: GetArrayLength(ja ...
- Windows系统设置与北京Internet时间同步
找到提供Ntp服务器的网址:http://support.ntp.org/我从中找到东北大学的: ntp.neu.edu.cn ( 202.118.1.46 ) 长话短说,下面开始设置: 修改后的值 ...
- Xilinx FPGA的专用时钟引脚及时钟资源相关
主要参考了https://www.eefocus.com/liu1teng/blog/12-02/237897_4533d.html .Xilinx UG471.UG472以及Xilinx Forum ...
- hdu 4870
Rating Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Sub ...
- JAVA如何获得数据库的字段及字段类型
Java获取数据库的表中各字段的字段名,代码如下: import java.sql.Connection;import java.sql.DriverManager;import java.sql.R ...