codeforces621C. Wet Shark and Flowers【求期望】
来源:互联网 发布:迪拜的警车知乎 编辑:程序博客网 时间:2024/05/16 05:00
#include<cstdio>#include<cstdlib>#include<cstring>#include<algorithm>#include<cmath>#include<queue>#include<list>#include<vector>using namespace std;struct Nodee{double P;long long l,r,num;}A[100010];int main(){int i,j,k,n;long long p;while(scanf("%d%I64d",&n,&p)!=EOF){for(i=0;i<n;++i){scanf("%I64d%I64d",&A[i].l,&A[i].r);long long ll,rr;if(A[i].l%p==0)ll=A[i].l;else ll=A[i].l/p*p+p;rr=A[i].r/p*p;if(ll==rr){A[i].num=1;}else if(ll>A[i].r){A[i].num=0;}else {A[i].num=(rr-ll)/p+1;}A[i].P=(A[i].num*1.0)/(1.0*(A[i].r-A[i].l+1));}double ans=0;for(i=0;i<n;++i){ans+=2000.0*(1.0-(1.0-A[i].P)*(1.0-A[(i+1)%n].P));}printf("%.6lf\n",ans);}return 0;}
0 0
- codeforces621C. Wet Shark and Flowers【求期望】
- Codeforce 题目621C Wet Shark and Flowers(期望)
- Codeforces 621C Wet Shark and Flowers 【期望】
- 【概率与期望】[CodeForces - 621C]Wet Shark and Flowers
- CodeForces 621 C. Wet Shark and Flowers(期望)
- CF621C - Wet Shark and Flowers
- Codeforces Round #341 (Div. 2) C. Wet Shark and Flowers (期望)
- Codeforces Round #341 (Div. 2) C. Wet Shark and Flowers(期望)
- Codeforces Round #341 (Div. 2) C Wet Shark and Flowers - 期望与概率
- Codeforces Round #341 (Div. 2)C. Wet Shark and Flowers(数学期望)
- Codeforces Round #341 (Div. 2) C - Wet Shark and Flowers 数学期望
- Codeforces 621C Wet Shark and Flowers
- Codeforces 621B Wet Shark and Flowers
- 621C. Wet Shark and Flowers【概率】
- 612 C. Wet Shark and Flowers
- codeforce 621C Wet Shark and Flowers
- Wet Shark and Flowers(cf621C)
- CodeForces 621C Wet Shark and Flowers
- 动态分区分配
- 机动车异地出险忌“私了”
- ReactNative开发中如何去掉iOS状态栏的"Loading from..."
- android CoordinatorLayout使用
- 基于大规模语料的新词发现算法
- codeforces621C. Wet Shark and Flowers【求期望】
- css篇——margin
- RecycleView 的使用
- opentsdb源码分析--添加
- vagrant+virtualbox
- 【Boost】boost库中智能指针概述
- 【转】[转]设置修改CentOS系统时区/时间
- TextView长按复制实现方法小结
- 四大通病让你错过面试机会