CodeForces 452C Magic Trick (排列组合)
#include <iostream>
#include <cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
double num[];
void init_arrary(){
for (int i = ; i <= ; ++i)
{
num[i] = num[i - ] + log(i);
}
}
double Cn(int m,int n){
return num[m] - num[n] - num[m-n];
}
int main(){
double n , m;
int i,j;
init_arrary();
while(cin >> n >> m){
double sum=,res;
res=;
for(i=;i<=min(m,n);i++){
sum=Cn(m,i)+Cn(n*m-m,n-i)-Cn(n*m,n);
sum=exp(sum);
res+=sum*i*i/n;//期望吧
}
cout<<res<<endl;
}
return ;
}
CodeForces 452C Magic Trick (排列组合)的更多相关文章
- Codeforces Gym 100187D D. Holidays 排列组合
D. Holidays Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100187/problem/D ...
- Codeforces Round #309 (Div. 2) C. Kyoya and Colored Balls 排列组合
C. Kyoya and Colored Balls Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contes ...
- [Codeforces 1228E]Another Filling the Grid (排列组合+容斥原理)
[Codeforces 1228E]Another Filling the Grid (排列组合+容斥原理) 题面 一个\(n \times n\)的格子,每个格子里可以填\([1,k]\)内的整数. ...
- [Codeforces 997C]Sky Full of Stars(排列组合+容斥原理)
[Codeforces 997C]Sky Full of Stars(排列组合+容斥原理) 题面 用3种颜色对\(n×n\)的格子染色,问至少有一行或一列只有一种颜色的方案数.\((n≤10^6)\) ...
- 【CodeForces】914 H. Ember and Storm's Tree Game 动态规划+排列组合
[题目]H. Ember and Storm's Tree Game [题意]Zsnuoの博客 [算法]动态规划+排列组合 [题解]题目本身其实并不难,但是大量干扰因素让题目显得很神秘. 参考:Zsn ...
- 【CodeForces】889 C. Maximum Element 排列组合+动态规划
[题目]C. Maximum Element [题意]给定n和k,定义一个排列是好的当且仅当存在一个位置i,满足对于所有的j=[1,i-1]&&[i+1,i+k]有a[i]>a[ ...
- Codeforces 140E(排列组合、dp)
要点 主要学到的东西:一个序列染色,相邻不染同色,恰用\(j\)种颜色的1.模式数.2.方案数.3.具体染色数. 从大的思路上来讲:先dp预处理出每一层的模式数:\(f[i][j]\)表示\(i\)个 ...
- Codeforces 991E. Bus Number (DFS+排列组合)
解题思路 将每个数字出现的次数存在一个数组num[]中(与顺序无关). 将出现过的数字i从1到num[i]遍历.(i from 0 to 9) 得到要使用的数字次数数组a[]. 对于每一种a使用排列组 ...
- CodeForces - 817B(分类讨论 + 排列组合)
题目链接 思路如下 这一题是:最菜的队伍只有三个人组成,我们只需对排序后的数组的 前三个元素进行分类讨论即可: a[3] != a[2] && a[3] != ar[1] a[3] = ...
随机推荐
- 使用Ramdisk 加速 Visualstudio 编译调试
一般来说ASP.NET在执行的时候,会先动态编译在目录 C:\Windows\Microsoft.NET\Framework64\版本\Temporary ASP.NET Files 由于每次修改程序 ...
- javascript线程解释(setTimeout,setInterval你不知道的事)
john resig写的一篇文章: 原文地址:http://ejohn.org/blog/how-javascript-timers-work/ 作为入门者来说,了解JavaScript中timer的 ...
- c++基础 之 面向对象特征一 : 继承
class Base { public: void f() { cout<<"void f()"<<endl<<endl; } void f(i ...
- php 设置字符集为utf-8
header("Content-Type:text/html;charset=utf-8");
- ubuntu FTP服务安装
//安装vsftp apt-get install vsftpd -y //增加账号 //1 查找 nologin位置 /usr/sbin/nologin useradd -d /alidata/ww ...
- webpack和webpack-dev-server的区别
第一: webpack只是构建 webpack-dev-server除了构建,还提供web服务 第二:webpack.config.json的路径参数 显然,entry都一样,因为都要知道需要构建 ...
- java 调用jdbc 实现excel和csv的导入和导出
jdbc 的连接 实体类 package com.gpdi.mdata.web.manage.database.data;public class DBQueryData {private Strin ...
- hadoop之hdfs学习
简介 HDFS(Hadoop Distributed File System )Hadoop分布式文件系统.是根据google发表的论文翻版的.论文为GFS(Google File System)Go ...
- c++ build options(important)
The C runtime library 4 versions: Multi-threaded (/MT) Multi-threaded Debug (/MTd) Multi-threaded D ...
- 3n+1
#include<iostream> using namespace std; int main() { int n; while(cin>>n) { int count=0; ...