tjut 3559
来源:互联网 发布:程序员对公司的建议 编辑:程序博客网 时间:2024/06/05 18:19
#include<iostream> #include<stdio.h> #include<stdlib.h> #include<string.h> #include<math.h> #include<vector> #include<map> #include<set> #include<queue> #include<stack> #include<string> #include<algorithm> using namespace std; typedef long long ll; #define inf 99999999 #define maxn 150 struct node{ int x,y; }a[10]; int g[10][10]; int n,m; double dp[5][26][6][6][6][6][6][6]; double ans[5]; int cas; void init() { int i,j; for(i=0;i<5;i++){ for(j=0;j<5;j++){ if((a[i].x-a[j].x)*(a[i].x-a[j].x)+(a[i].y-a[j].y)*(a[i].y-a[j].y)<=m*m )g[i][j]=1; else g[i][j]=0; } } } void dfs(int pos,int shengyu,int t[],double p) { int i,j; if(dp[pos][shengyu][t[0] ][t[1] ][t[2] ][t[3] ][t[4] ][5]==cas){ for(i=0;i<5;i++){ ans[i]+=dp[pos][shengyu][t[0] ][t[1] ][t[2] ][t[3] ][t[4] ][i]*p; } return; } if(shengyu==0){ for(i=0;i<5;i++){ if(t[i]==0){ dp[pos][shengyu][t[0] ][t[1] ][t[2] ][t[3] ][t[4] ][i]=1; ans[i]+=p; } else{ dp[pos][shengyu][t[0] ][t[1] ][t[2] ][t[3] ][t[4] ][i]=0; } } dp[pos][shengyu][t[0] ][t[1] ][t[2] ][t[3] ][t[4] ][5]=cas; return; } int cnt=0; for(i=0;i<5;i++){ if(pos!=i && t[i] && g[pos][i])cnt++; } if(cnt==0){ for(i=0;i<5;i++){ if(t[i]==0){ dp[pos][shengyu][t[0] ][t[1] ][t[2] ][t[3] ][t[4] ][i]=1; ans[i]+=p; } else{ dp[pos][shengyu][t[0] ][t[1] ][t[2] ][t[3] ][t[4] ][i]=0; } } dp[pos][shengyu][t[0] ][t[1] ][t[2] ][t[3] ][t[4] ][5]=cas; return; } double c[10]; for(i=0;i<5;i++)c[i]=ans[i]; for(i=0;i<5;i++){ if(i!=pos && t[i] && g[pos][i]){ t[i]--; dfs(i,shengyu-1,t,p/(cnt*1.0) ); t[i]++; } } dp[pos][shengyu][t[0] ][t[1] ][t[2] ][t[3] ][t[4] ][5]=cas; for(i=0;i<5;i++)dp[pos][shengyu][t[0] ][t[1] ][t[2] ][t[3] ][t[4] ][i]=(ans[i]-c[i])/p; } int main() { int i,j,k,t,h,kk,qq,q; int b[10]; cas=0; while(scanf("%d%d",&n,&m)!=EOF) { memset(ans,0,sizeof(ans)); cas++; for(i=0;i<5;i++){ scanf("%d%d",&a[i].x,&a[i].y); } for(i=0;i<5;i++){ scanf("%d",&b[i]); } init(); for(i=0;i<5;i++){ b[i]--; dfs(i,n,b,0.2); b[i]++; } printf("%.3f %.3f %.3f %.3f %.3f\n",ans[0],ans[1],ans[2],ans[3],ans[4]); } return 0; }
0 0
- tjut 3559
- tjut 5289
- tjut 5288
- tjut 5294
- tjut 2586
- tjut 5296
- tjut 5297
- tjut 5299
- tjut 5384
- tjut 5387
- tjut 5386
- tjut 5381
- tjut 5400
- tjut 5399
- tjut 5396
- tjut 5398
- tjut 5412
- tjut 5410
- SuppressWarnings注释
- iOS 开发笔记——The dependency `AFNetworking (~> 2.5.4)` is not used in any concrete target.
- [167]Two Sum II - Input array is sorted
- Android客户端与服务器端的数据通信中文乱码问题
- HDU 5863 cjj's string game(dp+矩阵快速幂)
- tjut 3559
- 欢迎使用CSDN-markdown编辑器
- REDIS实践应用
- windows下编译Caffe的MATLAB接口
- SIGPIPE信号详解
- 高通GPIO配置简介
- spring MVC 生成并下载Excel
- lucence的基本原理(一)
- 线程池 ExecutorService的使用