国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 學(xué)院 > 開發(fā)設(shè)計(jì) > 正文

HDU2843 概率論水題

2019-11-14 10:54:57
字體:
供稿:網(wǎng)友

啦啦啦啦啦     我是傳送門,快點(diǎn)我看題目

I Will Win

Time Limit: 2000/1000 MS (java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 398    Accepted Submission(s): 246PRoblem DescriptionDumbear likes to play table tennis with his daughter – Quan. But Dumbear found that Quan played table tennis better and better recently, Dumbear wondered that Quan would defeat him someday. So he wants to know if he will win in the next match.To simplify the problem, you can assume that the probability of Dumbear’s winning in each match is a constant number P (But Dumbear and you don’t know the number exactly). Of course 0 ≤ P ≤ 1. Dumbear had already taken N matches with Quan. And he won for M matches. He wants to know the expected probability of his winning for the next match. But Dumbear is very dumb, so he wants you to help him. InputEach line of the input file contains two numbers N and M (0 ≤ M ≤ N) indicate the number of the matches Dumbear had taken and the number of matches Dumbear had won. The last line of the input file contains two numbers "0 0". OutputFor each line, output two integers A and B indicates the expected probability of Dumbear’s winning for the next match is A / B. Make sure that gcd(A, B) = 1! Sample Input
1 12 10 0 Sample Output
2 31 2

題目大意:有個(gè)小孩和爸爸一起打乒乓球,小孩越打越好,爸爸就有點(diǎn)擔(dān)心了,想知道自己下一局贏的期望概率*.*,給你他們比賽的局?jǐn)?shù)n,爸爸贏的局?jǐn)?shù)m,要你求P,P的分子為A,分母為B

你們看  公式就是這么簡(jiǎn)單[轉(zhuǎn)載][HDU <wbr>2843][TJU <wbr>3319] <wbr>I <wbr>Will <wbr>Win,具體推導(dǎo)詳見百度,我們?cè)趺礃忧笞詈?jiǎn)分?jǐn)?shù)呢,當(dāng)然是用gcd咯,具體代碼如下:

#include <iostream>using namespace std;int gcd(int x,int y){	if (y==0) return x;	if(x<y)		return gcd(y,x);	else		return gcd(y,x%y);}int main(){	int n,m,a,b;	while(cin>>n>>m)	{		if(n==0&&m==0)			break;		a=m+1;		b=n+2;		int t=gcd(a,b);		a=a/t;		b=b/t;		cout<<a<<" "<<b<<endl;	}	return 0;}

發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 扎囊县| 金阳县| 丹凤县| 诸暨市| 三原县| 礼泉县| 壤塘县| 姜堰市| 遂昌县| 焦作市| 隆化县| 京山县| 恩平市| 进贤县| 宣武区| 安溪县| 商水县| 桑植县| 青海省| 拉萨市| 海伦市| 长宁区| 伊通| 罗城| 海盐县| 萨嘎县| 长乐市| 临安市| 怀集县| 满洲里市| 定边县| 抚顺市| 武威市| 灌南县| 武强县| 彰化市| 五家渠市| 宾川县| 宁乡县| 兴城市| 泌阳县|