hdu3625(第一类斯特林数)
与第二类有些区别!
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <algorithm>
#include <math.h>
#include <map>
#include <queue>
#include <sstream>
#include <iostream>
using namespace std;
#define INF 0x3fffffff typedef long long int LL;
#define N 22 LL dp[N][N];
LL sum[N]; int main()
{
//freopen("//home//chen//Desktop//ACM//in.text","r",stdin);
//freopen("//home//chen//Desktop//ACM//out.text","w",stdout);
dp[][]=;
sum[]=;
for(int i=;i<=;i++)
{
for(int j=;j<=i;j++)
{
dp[i][j]=dp[i-][j-]+(i-)*dp[i-][j];
}
}
for(int i=;i<=;i++)
sum[i]=sum[i-]*i;
int T;
scanf("%d",&T);
while(T--)
{
int n,k;
scanf("%d%d",&n,&k);
LL ans=;
for(int i=;i<=k;i++)
ans+=dp[n][i];
for(int i=;i<k;i++)
ans-=dp[n-][i];
printf("%.4lf\n",1.0*(double)ans/sum[n]);
}
return ;
}
hdu3625(第一类斯特林数)的更多相关文章
- 【组合数学:第一类斯特林数】【HDU3625】Examining the Rooms
		Examining the Rooms Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Othe ... 
- HDU3625(SummerTrainingDay05-N 第一类斯特林数)
		Examining the Rooms Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Othe ... 
- 【HDU 4372】 Count the Buildings (第一类斯特林数)
		Count the Buildings Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Othe ... 
- 如何快速求解第一类斯特林数--nlog^2n + nlogn
		目录 参考资料 前言 暴力 nlog^2n的做法 nlogn的做法 代码 参考资料 百度百科 斯特林数 学习笔记-by zhouzhendong 前言 首先是因为这道题,才去研究了这个玩意:[2019 ... 
- 【2019雅礼集训】【CF 960G】【第一类斯特林数】【NTT&多项式】permutation
		目录 题意 输入格式 输出格式 思路 代码 题意 找有多少个长度为n的排列,使得从左往右数,有a个元素比之前的所有数字都大,从右往左数,有b个元素比之后的所有数字都大. n<=2*10^5,a, ... 
- CF960G Bandit Blues 第一类斯特林数、NTT、分治/倍增
		传送门 弱化版:FJOI2016 建筑师 由上面一题得到我们需要求的是\(\begin{bmatrix} N - 1 \\ A + B - 2 \end{bmatrix} \times \binom ... 
- 【CF715E】Complete the Permutations(容斥,第一类斯特林数)
		[CF715E]Complete the Permutations(容斥,第一类斯特林数) 题面 CF 洛谷 给定两个排列\(p,q\),但是其中有些位置未知,用\(0\)表示. 现在让你补全两个排列 ... 
- 【CF960G】Bandit Blues(第一类斯特林数,FFT)
		[CF960G]Bandit Blues(第一类斯特林数,FFT) 题面 洛谷 CF 求前缀最大值有\(a\)个,后缀最大值有\(b\)个的长度为\(n\)的排列个数. 题解 完完全全就是[FJOI] ... 
- 【Luogu4609】建筑师(第一类斯特林数,组合数学)
		[Luogu4609]建筑师(组合数学) 题面 洛谷 题解 首先发现整个数组一定被最高值切成左右两半,因此除去最高值之后在左右分开考虑. 考虑一个暴力\(dp\) ,设\(f[i][j]\)表示用了\ ... 
随机推荐
- WPF SL      属性生成器
			在开发WPF 和SL应用的时候通用会用到MVVM模式,每次写到类属性的时候要不断的写属性更新时通知方法,写多了就嫌烦,就手写了个属性生成工具,在属性更新的时候添加了更新通知方法. 工具中支持自定义类对 ... 
- 2012全球SEO行业调查报告
			这份报告是SEOmoz对每两年一度举办的SEO行业调查进行的分析数据,上次调查是在2010年.该调查,主要围绕SEO从业人员的特征.工作内容时间分配比例.SEO相关消费和预算.对未来市场的看法.seo ... 
- jQuery国际化插件 jQuery.i18n.properties 【轻量级】
			jQuery.i18n.properties是一款轻量级的jQuery国际化插件,能实现Web前端的国际化. 国际化英文单词为:Internationalization,又称i18n,“i”为单词的第 ... 
- mybatis中分页查询
			1 如果在查询方法中有多个参数,可以使用map对象将所有数据都存储进去.比如分页查询,需要用到两个参数,可以将这两个参数包装到map中. 例子:分页查询 dao层方法 public List<S ... 
- ultragrid checkbox
			울트라그리드에 체크박스 넣을 사용하는 속성. cols["checked"].Header.Caption = ""; cols["checked ... 
- [Yii Framework] Share the session with memcache in Yii
			When developing distributed applications with Yii, naturally, we will face that we have to share the ... 
- 报错"the microsoft.jet.oledb.4.0 provider is not registered on the local machine"解决方案
			报错提示:"the microsoft.jet.oledb.4.0 provider is not registered on the local machine" 错误起因:wi ... 
- 基于Verilog语言的FIR滤波【程序和理解】
			一直想找一个简单.清晰.明了的fir滤波器的设计,终于找到了一个可以应用的,和大家分享一下,有助于FPGA新手入门. 1.说道fir滤波器,滤波系数肯定是最重要的,因为后面程序中涉及到滤波系数问题,所 ... 
- boost thread
			#include <cassert> #include <iostream> #include <boost/ref.hpp> #include <boost ... 
- CCNA2.0笔记_TCP/IP概述
			主机到主机层(传输层) TCP与UDP UDP的特点 运行于 OSI 模型和 TCP/IP 模型的传输层 为应用程序提供网络层接入而无需为可靠性机制付出多余开销 属无连接协议 提供有限的错误检查 提供 ... 
