hdu4405--Aeroplane chess(求期望)
2012-10-04 18:55
381 查看
分享一篇求期望的文章 http://kicd.blog.163.com/blog/static/126961911200910168335852/
从后往回推求期望
View Code
从后往回推求期望
View Code
//Accepted 4405 234MS 8248K 757 B Java import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); while(sc.hasNext()){ int n = sc.nextInt(); int m = sc.nextInt(); if(n == 0 && m == 0) break; double e[] = new double[n+1]; int useif[] = new int[n+1]; for(int i = 0; i < m ; ++i){ int a = sc.nextInt(); int b = sc.nextInt(); useif[a] = b; } e = 0; for(int i = n - 1; i >= 0 ; --i){ if(useif[i] > 0){ e[i] = e[useif[i]]; continue; } e[i] = 1; for(int j = 1; j < 7; j++){ if(i + j > n) break; else e[i] += e[i+j]/6; } } System.out.printf("%.4f",e[0]); System.out.println(); } } }
相关文章推荐
- 【HDU4405】Aeroplane chess [期望DP]
- hdu4405[Aeroplane chess] 有点懂了期望概率DP
- 【期望DP】HDU4405 Aeroplane chess
- HDU4405-Aeroplane chess(概率DP求期望)
- HDU4405:Aeroplane chess(概率dp & 期望)
- hdu4405 Aeroplane chess【概率DP+期望问题】
- hdu4405 Aeroplane chess 【期望dp】
- hdu4405 Aeroplane chess(期望dp)
- hdu 4405 Aeroplane chess【概率DP求期望】
- hdu4405_Aeroplane chess
- HDU 4405 Aeroplane chess(全期望公式-概率dp)
- HDU 4405 Aeroplane chess 概率dp求期望
- hdu4405--Aeroplane chess(概率dp第七弹:飞行棋游戏--2012年网络赛)
- HDU 4405 Aeroplane chess 期望dp
- HDU 4405 Aeroplane chess(概率DP求期望)
- HDU 4403(Aeroplane chess ,求期望,概率DP)
- hdu4405 Aeroplane chess
- HDU4405-Aeroplane chess(可能性DP需求预期)
- [hdu4405]Aeroplane chess(概率dp)
- Hdu 4405 Aeroplane chess DP求期望