CSU 1513 Kick the ball!
来源:互联网 发布:网络虚拟物品交易平台 编辑:程序博客网 时间:2024/04/29 09:36
DFS
题目的意思为 告诉你每个人进球概率的情况下 以当前比分结束这场比赛的概率是多少
数据量很小 直接枚举所有情况
注意下判断比赛结束时的条件 如果比赛已经结束但是分数未达到要求时 要停止搜索(坑)
当比赛已经结束且分数达到要求时 将当前状态的概率加上
#include <cstdio>#include <cstring>#include <algorithm>#include <cmath>#include <iostream>using namespace std;double a[7],b[7];int x,y;double ans;void dfs(int h,int c,int nh,int nc,double s,bool flag){ if(((6-nh)+h<c||(6-nc)+c<h)&&(x!=h||y!=c)) return; if(x==h&&y==c&&((6-nh)+h<c||(6-nc)+c<h)) { ans+=s; return; } if(nh==6&&nc==6) { if(h==c&&h==x&&c==y) ans+=s; return; } if(flag==0) { dfs(h+1,c,nh+1,nc,s*a[nh],1); dfs(h,c,nh+1,nc,s*(1-a[nh]),1); } else { dfs(h,c+1,nh,nc+1,s*b[nc],0); dfs(h,c,nh,nc+1,s*(1-b[nc]),0); }}int main(){ int o=1; while(~scanf("%lf",&a[1])) { int i,j,k,l; for(i=2;i<=5;i++) scanf("%lf",&a[i]); for(j=1;j<=5;j++) scanf("%lf",&b[j]); scanf("%d-%d",&x,&y); ans=0; dfs(0,0,1,1,1,0);//6个参数分别表示 a队得分 b队得分 a队当前踢球球员 b队当前踢球球员 当前状态概率 当前应当哪队踢 printf("Case %d: %.2lf",o++,ans*100); cout<<"%"<<endl; } return 0;}
0 0
- CSU 1513 Kick the ball!
- CSU 1513 Kick the ball!
- 【DFS】 CSU 1513 Kick the ball!
- CSU 1513 Kick the ball! ( 概率DP & DFS )
- CSU 1513 Kick the ball! 点球大战(DFS)
- csu Kick the ball! 概率+DFS
- CSU1513 Kick the ball!
- DFS csu1513 Kick the ball!
- Kick the ball!(dfs)湖南省赛第十届
- CSU1513 Kick the ball! 湖南10届省赛 dfs
- Portugal 2 1 minute has Pipansihuan Germany and USA tacit or kick the ball
- hdu1556 color the ball
- hdu1199Color the Ball
- HDOJ Color the ball
- The ball collide
- Color the ball
- Color the Ball
- hdoj_1556Color the ball
- Spring框架 Controller传递二维数组 到jsp的 js中
- Oracle的几个概念:数据库名,全局数据库名,SID,实例,命名空间,schema
- leetcode 日经贴,Cpp code -Longest Substring Without Repeating Characters
- 黑蚂蚁怎么吃补肾
- android开发之ToggleButton控件
- CSU 1513 Kick the ball!
- scala学习(二)----------------插入排序实现
- [架构设计] 组件和模块的区别
- 初次使用touch事件心得
- python xml解析例子
- JAVA一些概念问题
- cocos2d-x 3.5 一些cocos命令
- 基础控件 UIButton属性
- C编译器剖析_5.2.4 中间代码生成及优化_后缀表达式的翻译