Home > Database > Mysql Tutorial > body text

Codeforces Round (Div. 2) B. Dreamoon and WiFi (超几何

WBOY
Release: 2016-06-07 14:59:03
Original
987 people have browsed it

题目链接:Codeforces Round #273 (Div. 2) B. Dreamoon and WiFi 题意:“”表示前进1个单位,“-”表示后退1个单位,问以0为起点经过S1,S2两个命令后达到的位置相同的概率。 思路:统计“”和“-”的数量。如果S2中的“”或者“-”比S1中的多,概率是0。

题目链接:Codeforces Round #273 (Div. 2) B. Dreamoon and WiFi

题意:“+”表示前进1个单位,“-”表示后退1个单位,问以0为起点经过S1,S2两个命令后达到的位置相同的概率。

思路:统计“+”和“-”的数量。如果S2中的“+”或者“-”比S1中的多,概率是0。其他条件下,形成的是超几何分布。

 

AC代码:

 

#include <stdio.h>
#include <string.h>
int fac(int n,int m)
{
	int i,s=1;
	for(i=m;i>m-n;i--)
		s*=i;
	return s;
}
int C(int n,int m)
{
	int a=fac(n,m);
	int b=fac(n,n);
	return a/b;
}
double ipow(double n,int p)
{
	int i;
	double s=1.0;
	for(i=0;i<p s return int main char s1 len while addsum for if else subsum scanf m="0,pos=0,sum;" addsum-- subsum-- printf double ans>
<br>
<br>

</p>

</string.h></stdio.h>
Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!