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

首頁 > 學院 > 開發(fā)設(shè)計 > 正文

Codeforces Gym 100962 H. Hans Zimmer

2019-11-08 02:32:34
字體:
供稿:網(wǎng)友

Description

Hans wants to become a glass carver (a person who creates beautiful artwork by cutting the glass). He already has a rectangular piece of glass of size w  h millimeters, a diamond glass cutter and lots of enthusiasm. What he lacks is understanding of what to carve and how. In order not to waste time, he decided to PRactice the technique of carving. To do this, he makes vertical and horizontal cuts through the entire sheet. This process results in making smaller rectangular fragments of glass. Hans does not move the newly made glass fragments. In particular, a cut divides each fragment of glass that it goes through into smaller fragments. Hans doesn’t know how to make a great artwork, so he performs random cuts as follows. First, he tosses a fair coin to determine if he is going to cut the glass vertically or horizontally (that is, the probability of choosing each direction is 50%). After that, he chooses a uniformly distributed random real point on the corresponding side of the rectangle, and makes a cut through that point.All n random points and all n coin tosses are mutually independent. Hans is going to perform exactly n cuts. What he is interested in, is the fragment with the smallest area that is formed after he makes all cuts. Denote its area as ξ. Your task is to calculate E[ξ], the expected value of ξ.

Input

The only line of input contains three space-separated integers w, h and n (1≤w,h≤103,1≤n≤106), the size of the piece of glass and the number of cuts Hans is going to perform.

Output

Output the expected area of the smallest fragment formed after performing all cuts. Your answer will be considered correct if its relative error is no more than 10?4 (note that having absolute error no more that 10?4 is not enough).

題意

對給定的 h×w 的矩形在等概率的情況下任意橫切或縱切 n 下,將矩形分為若干塊,其中計最小一塊的面積為 ξ ,試求最小面積的期望 E[ξ]

分析

期望公式: E[ξ]=Σni=0Cin2n(i+1)2(n?i+1)2 ?膜拜隊友大神,給出期望公式 :haha:

T_T 然而此題不止一個坑點。顯然計算 2nn=1000000 時,各種數(shù)據(jù)類型都已經(jīng)無法表示。但套用 logexp 的策略可解決這個問題。因此,對期望公式加以轉(zhuǎn)換: E[ξ]=Σni=0elnCin?(nln2+2ln(i+1)+2ln(n?i+1)) 貌似非常卡精度,全部用 long double

代碼

#include<bits/stdc++.h>using namespace std;int main(){ int w, h, n; scanf("%d %d %d",&w,&h,&n); long double log_pow2 = log(2.0) * n; long double c_i_n = 0.0; long double ans = 0.0; for(int i=0;i<=n;i++) { if(i) c_i_n += log((n-i+1) * 1.0 / i); long double denominator = 2*log(i+1.0) + 2*log(n-i+1.0) + log_pow2; ans += exp( c_i_n - denominator ); } cout<<ans*h*w<<endl;}
發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 颍上县| 越西县| 读书| 孟州市| 南川市| 依安县| 邯郸县| 分宜县| 于都县| 民县| 铅山县| 弋阳县| 广平县| 安多县| 潮州市| 阿荣旗| 湾仔区| 兰溪市| 万安县| 静宁县| 岳池县| 通州市| 锦屏县| 定襄县| 锡林郭勒盟| 勃利县| 沂南县| 黑水县| 六盘水市| 上饶县| 济宁市| 永州市| 郑州市| 临夏县| 禄丰县| 长治县| 武宣县| 九龙坡区| 岢岚县| 泾源县| 闻喜县|