hdoj:2049
#include <iostream>
using namespace std; long long a[];
/*
n 个 数中 m个错排
转化为:充n个数中选取m个数,共有C(n,m)中,选取的m个数进行全部错排
*/
/*
排列
*/
long long fn(int a,int b)
{
long long res = ;
for (int i = a; i <= b; i++)
{
res *= i;
}
return res;
} long long fC(int n, int m)
{
long long s1 = fn(m+,n);
long long s2 = fn(,n-m);
return s1 / s2;
} int main()
{
int T,n,m;
cin >> T;
a[] = ;
a[] = ;
for (int i = ; i <= ; i++)
{
a[i] = (i - ) * (a[i - ] + a[i - ]); // 全部错排
} while (T--)
{
cin >> n >> m;
long long res = a[m] * fC(n, m);
cout << res << endl;
}
}
部分错排
http://acm.hdu.edu.cn/showproblem.php?pid=2049
hdoj:2049的更多相关文章
- hdoj 2049 错排
代码: #include <stdio.h> int main(){ int n,a,b,i,j; __int64 s[22],h[22]; s[1]=0; s[2]=1; s[3]=2; ...
- HDOJ(HDU).2044-2049 递推专题
HDOJ(HDU).2044-2049 递推专题 点我挑战题目 HDU.2044 题意分析 先考虑递推关系:从1到第n个格子的时候由多少种走法? 如图,当n为下方格子的时候,由于只能向右走,所以有2中 ...
- HDOJ 1009. Fat Mouse' Trade 贪心 结构体排序
FatMouse' Trade Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) ...
- HDOJ 2317. Nasty Hacks 模拟水题
Nasty Hacks Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Tota ...
- HDOJ 1326. Box of Bricks 纯水题
Box of Bricks Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) To ...
- HDOJ 1004 Let the Balloon Rise
Problem Description Contest time again! How excited it is to see balloons floating around. But to te ...
- hdoj 1385Minimum Transport Cost
卧槽....最近刷的cf上有最短路,本来想拿这题复习一下.... 题意就是在输出最短路的情况下,经过每个节点会增加税收,另外要字典序输出,注意a到b和b到a的权值不同 然后就是处理字典序的问题,当松弛 ...
- HDOJ(2056)&HDOJ(1086)
Rectangles HDOJ(2056) http://acm.hdu.edu.cn/showproblem.php?pid=2056 题目描述:给2条线段,分别构成2个矩形,求2个矩形相交面 ...
- 继续node爬虫 — 百行代码自制自动AC机器人日解千题攻占HDOJ
前言 不说话,先猛戳 Ranklist 看我排名. 这是用 node 自动刷题大概半天的 "战绩",本文就来为大家简单讲解下如何用 node 做一个 "自动AC机&quo ...
随机推荐
- BZOJ.5290.[AHOI/HNOI2018]道路(树形DP)
BZOJ LOJ 洛谷 老年退役选手,都写不出普及提高DP= = 在儿子那统计贡献,不是在父亲那统计啊!!!(这样的话不写这个提高DP写记忆化都能过= =) 然后就令\(f[x][a][b]\)表示在 ...
- IDEA常用配置
一.安装Activiti 1.File -> Settings -> Plugins -> 搜索actiBPM 2.解决中文乱码问题 修改IDEA的安装目录中的idea.exe.vm ...
- Ubuntu安装python3虚拟环境
大多数Linux自带python2.7,而Ubuntu1.6也自带python3.x,本文章主要记录virtualenv+vitualenvwrapper使用python3虚拟环境 虚拟环境好处不多说 ...
- 简单的C程序
1.最简单的C程序 #include<stdio.h> //预编译处理指令 int main() // 定义主函数 { printf("hello world"); } ...
- 工程管理之makefile与自动创建makefile文件过程
(风雪之隅 http://www.laruence.com/2009/11/18/1154.html) Linux Makefile自动编译和链接使用的环境 想知道到Linux Makefile系统的 ...
- C++程序设计方法3:禁止自动类型转换
禁止自动类型转换 explicit #include <iostream> using namespace std; class Src;//前置类型声明,因为在Dst中要用到Src的类 ...
- 编程菜鸟的日记-初学尝试编程-C++ Primer Plus 第4章编程练习5
#include <iostream>using namespace std;struct CandyBar{ char kind[20]; float weight; int calor ...
- ES6_入门(3)_顶层对象属性
//顶层对象属性:在ES5中,顶层对象的属性与全局变量是等价的.以下代码中,为顶层对象的属性赋值与全局变量的赋值,是同一件事. window.a=10; console.log(window.a); ...
- 【枚举】Consonant Fencity @upcexam5110
时间限制: 3 Sec 内存限制: 512 MB 题目描述 There are two kinds of sounds in spoken languages: vowels and consonan ...
- JAVA自学笔记13
JAVA自学笔记13 1.StringBuffer类 1)线程安全的可变字符序列 线程安全(即同步) 2)StringBuffer与String的区别:一个可变一个不可变 3)构造方法: ①publi ...