codeforces 30C Shooting Gallery (概率dp)
来源:互联网 发布:功德人生软件下载 编辑:程序博客网 时间:2024/05/29 08:43
题意:
给出n个会定时出现的靶子,每个靶子给出出现的时间坐标和能打中概率,问打中靶子数的期望最大值。
题解:
简单的概率dp,dp[i]表示以i为结尾打中靶子数期望的最大值。注意精度!
#include<iostream>#include<math.h>#include<stdio.h>#include<algorithm>#include<string.h>#include<vector>#include<map>using namespace std;typedef long long lld;const int oo=0x3f3f3f3f;const lld OO=1LL<<61;const int MOD=1000000007;#define eps 1e-6#define maxn 1005double dp[maxn];struct NODE{ double x,y,t,p;}a[maxn];bool cmp(NODE n1,NODE n2){ return n1.t<n2.t-eps;}double dis(NODE n1,NODE n2){ return sqrt(1.0*(n1.x-n2.x)*(n1.x-n2.x)+1.0*(n1.y-n2.y)*(n1.y-n2.y));}int main(){ int n; while(scanf("%d",&n)!=EOF) { for(int i=1;i<=n;i++) scanf("%lf %lf %lf %lf",&a[i].x,&a[i].y,&a[i].t,&a[i].p); sort(a+1,a+1+n,cmp); memset(dp,0,sizeof dp); dp[0]=0.0; double ans=0.0; for(int i=1;i<=n;i++) { for(int j=0;j<i;j++) if(a[i].t-a[j].t>dis(a[j],a[i])-eps||j==0) { dp[i]=max(dp[i],dp[j]+a[i].p); } ans=max(ans,dp[i]); } printf("%.10lf\n",ans); } return 0;}/**10 0 0 0.520 0 0 0.65 0 5 0.7*/
0 0
- codeforces 30C - Shooting Gallery DP 概率
- codeforces 30C Shooting Gallery (概率dp)
- CodeForces 30C Shooting Gallery 简单dp
- Codeforces 30C Shooting Gallery【dp】
- CodeForces 30C — Shooting Gallery
- 【20.00%】【codeforces 44G】Shooting Gallery
- codeforces 601C (概率DP)
- codeforces 28C (概率DP)
- codeforces 601C(概率dp)
- codeforces 280c 概率dp + dfs
- Codeforces 54C First Digit Law 数位dp+概率dp
- Codeforces 482C Game with Strings(dp+概率)
- Codeforces 513C Second price auction 概率dp 求期望
- Codeforces 54C First Digit Law —— 概率DP
- CodeForces 28c Bath Queue(概率dp)
- codeforces 698 C. LRU (概率与期望+状压DP)
- Codeforces 839C Journey (树形dp + 概率期望)
- CodeForces 28 C.Bath Queue(概率DP+组合数学)
- Oracle函数介绍:decode
- Phaser 编程技巧
- Tinycore学习笔记_快速安装系统
- java编程思想第四版习题_8.11
- Leetcode_Add Binary
- codeforces 30C Shooting Gallery (概率dp)
- WebClient访问FTP服务器时505错误
- 基于百度地图API的微信周边搜索
- 第五届中国(北京)国际智能家居产业博览会
- 寒假集训.Skew Binary
- 【转载】jsessionid
- POJ-1008 Maya Calendar
- java编程思想第四版习题_8.13
- VC INI文件读写