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的更多相关文章

  1. 水题 Codeforces Round #302 (Div. 2) A Set of Strings

    题目传送门 /* 题意:一个字符串分割成k段,每段开头字母不相同 水题:记录每个字母出现的次数,每一次分割把首字母的次数降为0,最后一段直接全部输出 */ #include <cstdio> ...

  2. 水题 Codeforces Round #300 A Cutting Banner

    题目传送门 /* 水题:一开始看错题意,以为是任意切割,DFS来做:结果只是在中间切出一段来 判断是否余下的是 "CODEFORCES" :) */ #include <cs ...

  3. 水题 Codeforces Round #299 (Div. 2) A. Tavas and Nafas

    题目传送门 /* 很简单的水题,晚上累了,刷刷水题开心一下:) */ #include <bits/stdc++.h> using namespace std; ][] = {" ...

  4. 水题 Codeforces Round #304 (Div. 2) A. Soldier and Bananas

    题目传送门 /* 水题:ans = (1+2+3+...+n) * k - n,开long long */ #include <cstdio> #include <algorithm ...

  5. 水题 Codeforces Round #303 (Div. 2) A. Toy Cars

    题目传送门 /* 题意:5种情况对应对应第i或j辆车翻了没 水题:其实就看对角线的上半边就可以了,vis判断,可惜WA了一次 3: if both cars turned over during th ...

  6. 水题 Codeforces Round #286 (Div. 2) A Mr. Kitayuta's Gift

    题目传送门 /* 水题:vector容器实现插入操作,暴力进行判断是否为回文串 */ #include <cstdio> #include <iostream> #includ ...

  7. 构造水题 Codeforces Round #206 (Div. 2) A. Vasya and Digital Root

    题目传送门 /* 构造水题:对于0的多个位数的NO,对于位数太大的在后面补0,在9×k的范围内的平均的原则 */ #include <cstdio> #include <algori ...

  8. 水题 Codeforces Round #306 (Div. 2) A. Two Substrings

    题目传送门 /* 水题:遍历一边先找AB,再BA,再遍历一边先找BA,再AB,两种情况满足一种就YES */ #include <cstdio> #include <iostream ...

  9. 水题 Codeforces Round #308 (Div. 2) A. Vanya and Table

    题目传送门 /* 水题:读懂题目就能做 */ #include <cstdio> #include <iostream> #include <algorithm> ...

  10. 水题 Codeforces Round #307 (Div. 2) A. GukiZ and Contest

    题目传送门 /* 水题:开个结构体,rk记录排名,相同的值有相同的排名 */ #include <cstdio> #include <cstring> #include < ...

随机推荐

  1. Golang Global Variable access

    golang 中全局变量的问题. ------------------------------------------------------------------ 17down votefavor ...

  2. Android 使用ListView的A-Z字母排序功能实现联系人模块

    在上一篇文章其中,主要学习了ListView的A-Z字母排序功能以及依据输入框的输入值改变来过滤搜索结果,假设输入框里面的值为空.更新为原来的列表,否则为过滤数据列表,包含汉字转成拼音的功能.假设你还 ...

  3. atitit. hb 原生sql跨数据库解决原理 获得hb 数据库类型执行期获得Dialect

    atitit. hb 原生sql跨数据库解决原理 获得hb 数据库类型执行期获得Dialect   #-----原理 Hibernate 执行期获得Dialect   2010-07-28 12:59 ...

  4. github 新建远程仓库 及 删除远程仓库

    一.新建远程仓库 1.点击 ' + ' 号 2.选择 ' new repository ' 3.填写信息  创建仓库 二.删除远程仓库 1.点击 ' Settings ' 按钮 2.滑动到最底部,点击 ...

  5. v-bind指令

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  6. 性能问题案例02——sybase连接堵塞问题

    现象:近期现场反馈一个问题.系统在审批的时候,常常卡死.整个系统全然用不了,浏览器訪问处于loading的状态. 排查: 1.一般系统挂了首先想到内存问题,可是现象是loading,也就是说没有挂,线 ...

  7. 项目Alpha冲刺(团队8/10)

    项目Alpha冲刺(团队8/10) 团队名称: 云打印 作业要求: 项目Alpha冲刺(团队) 作业目标: 完成项目Alpha版本 团队队员 队员学号 队员姓名 个人博客地址 备注 221600412 ...

  8. 嵌入式开发之davinci--- 8168 question about capture PAL on 8168

    http://e2e.ti.com/support/dsp/davinci_digital_media_processors/f/717/t/340483.aspx?pi199607=2

  9. Marlin固件之—:基础入门与測试

    一.Marlin的简介 Marlin固件是一个3D打印的开源固件,3D打印固件有很多,Marlin最为健全和强大,当然相对也会复杂一些.使用Gcode控制爱.Gcode是数控机床等工控控制使用范围较广 ...

  10. fstab文件解析

    1 这个文件的用途 这个文件是启动时自动挂载指定的磁盘或者分区到系统目录下用的,提供给mount命令用. 2 文件解析 每一行是一次mount操作. 磁盘或者分区    挂载的目录     挂载的磁盘 ...