gcj 2008 apac problem c
来源:互联网 发布:高中背英语单词软件 编辑:程序博客网 时间:2024/06/05 05:35
#include<iostream>#include<cstdio>#include<cstring>#include<algorithm>#define MAX_M 25using namespace std;typedef long long ll;int M,X;int T,temp;double P;double dp[2][(1<<MAX_M)+1];void solve(){ int n=1<<M; double *prv =dp[0], *nxt=dp[1]; memset(prv,0,sizeof(double)*(n+1)); prv[n]=1.0; for(int r=0;r<M;r++) { for(int i=0;i<=n;i++) { int jub=min(i,n-i); double t=0.0; for(int j=0;j<=jub;j++) { t=max(t,P*prv[i+j]+(1-P)*prv[i-j]); } nxt[i]=t; } swap(prv,nxt); } int i=(ll) X*n/1000000; printf("Case #%d: %.6lf\n",temp-T,prv[i]);}int main(){ freopen("/Users/xxxxxx/Desktop/input.txt","r",stdin); freopen("/Users/xxxxxx/Desktop/output.txt","w",stdout); cin>>T; temp=T; while(T--) { scanf("%d%lf%d",&M,&P,&X); solve(); } return 0;}
看的挑战才写出来 注意在M>=2的时候 你的策略有很多 ,所以钱可以从0-2*当前格子 但要保证不超过n 所以用jub 来限制循环的范围
0 0
- gcj 2008 apac problem c
- GCJ--Millionaire (2008 APAC local onsites C)
- GCJ--Millionaire (2008 APAC local onsites C)
- GCJ 2008 APAC local onsites C Millionaire
- GCJ 2008 APAC local onsites C(Millionaire) (dp+离散化)
- 【翻译】GCJ 2008 APAC local onsites C Millionaire 题解
- 2008 APAC local onsites Problem C. Millionaire
- GCJ Round 1A 2008 Problem C. Numbers
- Code Jam 2008 APAC local onsites Problem C. Millionaire —— 概率DP
- Round C APAC Test 2017 Problem C. Evaluation
- Problem C. Evaluation Google APAC 2017 University Test Round C
- Round C APAC Test 2017 Problem A. Monster Path (C++)
- Round C APAC Test 2017 Problem B. Safe Squares (C++)
- Google APAC test 2015 Round B Problem C - Card Game
- Round A APAC Test 2016 Problem C. gCampus 最短路
- Google 2015 APAC Round A Problem C - Addition
- Round C APAC Test 2017 Problem A. Monster Path
- Round C APAC Test 2017 Problem B. Monster Path
- iOS开发系列---如何从菜鸟到专家
- 二叉树的遍历
- java继承
- Java—内部类(普通,静态,局部,匿名)
- Maven学习总结(一)——Maven入门
- gcj 2008 apac problem c
- Golang 语法 知识点提要
- 类。字段。方法。属性之间的定义及部分区别。
- 使用iscroll的问题与解决办法
- python json操作
- Shell部分7
- CodeLite 出现'auto' changes meaning in C++11的错误提示时的解决方法
- HBuilder如何与服务器上传代码
- Web Cache的实现