UVA 10056 What is the Probability ?
2015-12-29 11:09
381 查看
题目描述
简单的推一下就行了
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std;
int n,an;
double p;
double ans,a1;
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
scanf("%d%lf%d",&n,&p,&an);
if(p==0) ans=0;
else
{
a1=p*(1-pow(1-p,1000*n))/(1-pow(1-p,n));
//cout<<a1<<" ";
ans=a1*pow(1-p,an-1);
}
printf("%.4lf\n",ans);
}
return 0;
}
简单的推一下就行了
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std;
int n,an;
double p;
double ans,a1;
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
scanf("%d%lf%d",&n,&p,&an);
if(p==0) ans=0;
else
{
a1=p*(1-pow(1-p,1000*n))/(1-pow(1-p,n));
//cout<<a1<<" ";
ans=a1*pow(1-p,an-1);
}
printf("%.4lf\n",ans);
}
return 0;
}
相关文章推荐
- Optimizilla中文在线无损压缩JPG、PNG图片,不降低画质有效减少图片文件大小
- android自定义控件基础
- 将raw里面的数据库文件写入到data中
- hadoop 动态调整mapred参数
- js中的字符串长度
- redis上tomcat和session共享的问题
- ubuntu su 密码
- (转)Android系统自带Activity样式(@android:style/)
- Android禁止横屏竖屏切换
- SeekBar 圆角问题
- iOS开发笔记--详解苹果的黑魔法 – KVO 的奥秘
- 一行代码解决各种IE兼容问题,IE6,IE7,IE8,IE9,IE10
- Qt浅谈之三十八下拉列表框
- 详解javascript之delete操作符
- phpwind图文安装2
- 升级Python版本脚本
- EF学习笔记——生成自定义实体类
- 引导界面(只显示一次)的实现
- Android RSA加密解密
- 【Hibernate3】(3)数据库生成策略