HDU 5984 數學期望
阿新 • • 發佈:2017-10-12
define eps else 區域 比較 double scan clu file
對長為L的棒子隨機取一點分割兩部分,拋棄左邊一部分,重復過程,直到長度小於d,問操作次數的期望。
區域賽的題,比較基礎的概率論,我記得教材上有道很像的題,對1/len積分,$ln(L)-ln(d)+1$。
/** @Date : 2017-10-06 14:32:03 * @FileName: HDU 5984 數學期望.cpp * @Platform: Windows * @Author : Lweleth ([email protected]) * @Link : https://github.com/ * @Version : $Id$ */ #include <bits/stdc++.h> #define LL long long #define PII pair #define MP(x, y) make_pair((x),(y)) #define fi first #define se second #define PB(x) push_back((x)) #define MMG(x) memset((x), -1,sizeof(x)) #define MMF(x) memset((x),0,sizeof(x)) #define MMI(x) memset((x), INF, sizeof(x)) using namespace std; const int INF = 0x3f3f3f3f; const int N = 1e5+20; const double eps = 1e-8; int main() { int n; cin >> n; while(n--) { double a, b; scanf("%lf%lf", &a, &b); if(a <= b) printf("0.000000\n"); else printf("%.6lf\n", log(a/b) + 1); } return 0; }
HDU 5984 數學期望