概率论

本文提供了一种解决FZU2132概率题目的方法,通过计算组合数和概率来求解特定条件下成功的概率。代码中使用了C语言实现的组合数计算函数,并结合概率公式完成解答。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

题目链接: FZU 2132
第一道概率论题目,说白了,就是算概率
另外推荐一篇博文 http://blog.youkuaiyun.com/crescent__moon/article/details/17347379
讲的很好
#include<cstdio> #include<cstring> #include<cstdlib> #include<math.h> #include<algorithm> #include <vector> #include <queue> using namespace std; #define INF 0x3f3f3f3f #define N 200 double C(int n, int k) { double ans=1; int cnt=0, kk; kk=k; for(int i=n; i>=1; i--) { cnt++; ans*=1.0*i/kk; kk--; if(cnt==k) break; } return ans; } int main() { int T, n, m; double x, ans; scanf("%d", &T); while(T--) { ans=0; scanf("%d%d%lf", &n, &m, &x); for(int i=n; i>=m; i--) ans+=C(n, i)*pow(x, i)*pow((1-x), (n-i)); printf("%.4f\n", ans); } return 0; }

转载于:https://www.cnblogs.com/9968jie/p/5517200.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值