(水题)Codeforces - 630H - Benches
https://codeforces.com/problemset/problem/630/H
又一个组合数学的问题,我们先考虑在 $n$ 列中选出 $5$ 列来放椅子,然后对第一列有 $n$ 种放法,第二列有 $n-1$ 种放法……最后就是 $C_n^5A_n^5$ ……
居然没有注意到会溢出,这里可以用大数或者是及时除以因子保证不溢出。因为结果是比较小所以可以试试能不能保证不在64位里溢出。
#include<bits/stdc++.h>
using namespace std;
#define ll long long ll C(int n,int m){
ll res=;
for(int i=;i<m;i++){
res*=(n-i);
}
ll res2=;
for(int i=;i<m;i++){
res2*=(i+);
}
return res/res2;
} ll A(int n,int m){
ll res=;
for(int i=;i<m;i++){
res*=(n-i);
}
return res;
} int n;
int main(){ int n;
scanf("%d",&n);
printf("%lld\n",C(n,)*A(n,)); }
(水题)Codeforces - 630H - Benches的更多相关文章
- 水题 Codeforces Round #302 (Div. 2) A Set of Strings
题目传送门 /* 题意:一个字符串分割成k段,每段开头字母不相同 水题:记录每个字母出现的次数,每一次分割把首字母的次数降为0,最后一段直接全部输出 */ #include <cstdio> ...
- 水题 Codeforces Round #300 A Cutting Banner
题目传送门 /* 水题:一开始看错题意,以为是任意切割,DFS来做:结果只是在中间切出一段来 判断是否余下的是 "CODEFORCES" :) */ #include <cs ...
- 水题 Codeforces Round #299 (Div. 2) A. Tavas and Nafas
题目传送门 /* 很简单的水题,晚上累了,刷刷水题开心一下:) */ #include <bits/stdc++.h> using namespace std; ][] = {" ...
- 水题 Codeforces Round #304 (Div. 2) A. Soldier and Bananas
题目传送门 /* 水题:ans = (1+2+3+...+n) * k - n,开long long */ #include <cstdio> #include <algorithm ...
- 水题 Codeforces Round #303 (Div. 2) A. Toy Cars
题目传送门 /* 题意:5种情况对应对应第i或j辆车翻了没 水题:其实就看对角线的上半边就可以了,vis判断,可惜WA了一次 3: if both cars turned over during th ...
- 水题 Codeforces Round #286 (Div. 2) A Mr. Kitayuta's Gift
题目传送门 /* 水题:vector容器实现插入操作,暴力进行判断是否为回文串 */ #include <cstdio> #include <iostream> #includ ...
- 构造水题 Codeforces Round #206 (Div. 2) A. Vasya and Digital Root
题目传送门 /* 构造水题:对于0的多个位数的NO,对于位数太大的在后面补0,在9×k的范围内的平均的原则 */ #include <cstdio> #include <algori ...
- 水题 Codeforces Round #306 (Div. 2) A. Two Substrings
题目传送门 /* 水题:遍历一边先找AB,再BA,再遍历一边先找BA,再AB,两种情况满足一种就YES */ #include <cstdio> #include <iostream ...
- 水题 Codeforces Round #308 (Div. 2) A. Vanya and Table
题目传送门 /* 水题:读懂题目就能做 */ #include <cstdio> #include <iostream> #include <algorithm> ...
- 水题 Codeforces Round #307 (Div. 2) A. GukiZ and Contest
题目传送门 /* 水题:开个结构体,rk记录排名,相同的值有相同的排名 */ #include <cstdio> #include <cstring> #include < ...
随机推荐
- HDU 3820 Golden Eggs( 最小割 奇特建图)经典
Golden Eggs Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Tota ...
- Android OpenGL ES(六)----进入三维在代码中创建投影矩阵和旋转矩阵
我们如今准备好在代码中加入透视投影了. Android的Matrix类为它准备了两个方法------frustumM()和perspectiveM(). 不幸的是.frustumM()的个缺陷,它会影 ...
- Nova虚拟机启动提示libvirtError
OpenStack自动化安装基本折腾完毕,装一次大概也就10分钟,但是装完后今天我的虚拟机起不来,经过查找log发 现如下图提示: 已经到这里,说明已经过了nova-sheduler那一关,跟踪一下代 ...
- 信雅达面试题atoi函数实现
atoi函数: 功 能: 把字符串转换成整型数. 名字来源:ASCII to integer 的缩写. 原型: int atoi(const char *nptr); 函数说明 参数nptr字符串,如 ...
- LeetCode题解(19)--Remove Nth Node From End of List
https://leetcode.com/problems/remove-nth-node-from-end-of-list/ 原题: Given a linked list, remove the ...
- npm ERR! code EINTEGRITY npm ERR! sha1- 报错解决办法
npm ERR! code EINTEGRITY npm ERR! sha1- 报错日志 npm ERR! code EINTEGRITY npm ERR! sha1-OGchPo3Xm/Ho8jAM ...
- PowerDesigner逆向工程,从SQL Server数据库生成Physical Model
提前声明:这种方式貌似只能是Power Designer安装在数据库服务器的时候才可以,因为我按照成功的这个再去从本机逆向连接远程服务器的时候,一直提示:test failed......不讲了,尴尬 ...
- antV G6流程图在Vue中的使用
最近我司项目中需要加入流程图制作功能,于是乎百度各种找可视化绘制拓扑图的轮子,大部分都是国外的,看文档太吃力,不过好在最终让我发现了AntV G6流程图图表库,最新版为2.0,不过编辑器在2.0版本还 ...
- /dev下添加设备节点的方法步骤(通过device_create)
将自己开发的内核代码加入到Linux内核中,需要3个步骤: 1.确定把自己开发代码放入到内核合适的位置 将demo_chardev.c文件拷贝到.../drivers/char/目录下. demo_c ...
- futimens函数的使用【学习笔记】
#include "apue.h" #include <fcntl.h> int main(int argc,char *argv[]) { int i,fd; str ...