/*
 概率计算:按时间为阶段,每个点由上一阶段周围的四个点来维护。
 注意事项:1.时间O(N^3*T),在问题的边缘时间,所以打表计算。
         2.关于概率的求解,如果遇到就结束了,所以向后走就说明
          之前没有碰到,所以不用前面的碰到的概率计算后面的值。
*/

View Code

 1 #include <stdio.h> 2 #include <string.h> 3  4 double answ[ 51 ] = { 5     0.0000,0.6667,0.0000,0.4074,0.0000, 6     0.3361,0.0000,0.2928,0.0000,0.2629, 7     0.0000,0.2407,0.0000,0.2233,0.0000, 8     0.2092,0.0000,0.1975,0.0000,0.1875, 9     0.0000,0.1789,0.0000,0.1714,0.0000,10     0.1648,0.0000,0.1589,0.0000,0.1536,11     0.0000,0.1487,0.0000,0.1443,0.0000,12     0.1403,0.0000,0.1366,0.0000,0.1332,13     0.0000,0.1300,0.0000,0.1270,0.0000,14     0.1243,0.0000,0.1217,0.0000,0.1192};15 16 /*17 18 double maps[ 100 ][ 100 ][ 100 ];19 short  dxdy[ 4 ][ 2 ] = {1,0,0,1,-1,0,0,-1};20 21 void madelist()    // 打表程序 22 {23     for ( int n = 1 ; n < 100 ; n += 2 ) {24         double sum = 0.0;25         memset( maps, 0, sizeof( maps ) );26         maps[ 0 ][ n/2 ][ n/2 ] = 1.0;27         for ( int t = 0 ; t < n ; ++ t )28         for ( int i = 0 ; i < n ; ++ i )29         for ( int j = 0 ; j < n ; ++ j )30         for ( int k = 0 ; k < 4 ; ++ k ) {31             int x = i+dxdy[ k ][ 0 ];32             int y = j+dxdy[ k ][ 1 ];33             if ( x > 0 && x < n-1 && y > 0 && y < n-1 )34                 maps[ t+1 ][ i ][ j ] += 0.25*maps[ t ][ x ][ y ];35             else if ( ( x == 0 && y == 0 ) || ( x == 0 && y == n-1 ) ||36                     ( x== n-1 && y == 0 ) || ( x == n-1 && y == n-1 ) )37                 maps[ t+1 ][ i ][ j ] += 0.5*maps[ t ][ x ][ y ];38             else maps[ t+1 ][ i ][ j ] += 1.0/3*maps[ t ][ x ][ y ];39             if ( i == n/2 && j == t ) {40                 sum += maps[ t+1 ][ i ][ j ];41                 maps[ t+1 ][ i ][ j ] = 0.0;42             }43         }44         printf("%.4lf,",sum);45     }46 }47 */48 49 int main()50 {51     int m;52     while ( ~scanf("%d",&m) ) 53         printf("%.4lf\n",answ[ m/2 ]);54     return 0;55 }

转载于:https://www.cnblogs.com/-xiaobai-/archive/2011/08/18/2144243.html

zoj2271 Chance to Encounter a Girl(DP)相关推荐

  1. 英语学习打卡day10

    2023.2.4 1.In so far as/insofar as 到这种程度 2.inquiry 调查=research 3.fellow my fellow Chinese 中国同胞 my fe ...

  2. 4000 essential english words推荐学习

    很多同学让我讲一讲4000 essential english words 这套教材,今天就详细介绍一下这套教材,附带导学视频,具体如下: 一.教材介绍 The 600 words in each b ...

  3. P3609 [USACO17JAN] Hoof, Paper, Scissor G

    题目背景 本题与 银组同名题目 在题意上一致,唯一的差别在于对变手势次数的限制. 题目描述 你可能玩过"石头,剪刀,布",这个游戏在奶牛中同样流行,不过它的名字变成了"蹄 ...

  4. Educational Codeforces Round 13 E. Another Sith Tournament 状压dp

    E. Another Sith Tournament 题目连接: http://www.codeforces.com/contest/678/problem/E Description The rul ...

  5. hdu 2833(Floyd + dp)

    WuKong Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Problem D ...

  6. Gym 101933 A(dp)

    传送门: 题面: A. Altruistic Amphibians time limit per test 3.0 s memory limit per test 512 MB input stand ...

  7. 【HDU - 6558】The Moon(期望dp)

    题干: Random Six is a FPS game made by VBI(Various Bug Institution). There is a gift named "Beta ...

  8. 【LightOJ - 1031】Easy Game (区间dp,博弈)

    题干: You are playing a two player game. Initially there are n integer numbers in an array and player  ...

  9. Codeforces 148D. Bag of mice(概率dp)

    Codeforces 148D. Bag of mice(概率dp) Description The dragon and the princess are arguing about what to ...

最新文章

  1. LeetCode简单题之数组元素积的符号
  2. 键盘的扫描码虚拟码概念 常见Windows键盘按键虚拟码
  3. linux u盘分区 mdev 卸载问题,嵌入式linux 实现mdev SD卡和U盘自动挂载和卸载的方法 mdev.conf...
  4. iPhone 5今日大限已至!不升级全部变砖
  5. 退出命令_利好消息!上级命令:乡村医生满60岁要办退出手续
  6. 关于 TApplication 详解 六 ---- TColorDialog
  7. TiDB DevCon2018.tick(1.20)
  8. 计算机思维论文1万字,计算机思维学论文选题 计算机思维论文题目怎么取
  9. http://trans.godict.com/index.php
  10. 15W无线充电芯片介绍
  11. 三次握手的过程、四次挥手、为什么要进行第三次握手、为什么要进行四次挥手
  12. npm error: Maximum call stack size exceeded
  13. 野人参多少钱一斤?走进野人参高价格背后的秘密
  14. Stage 222222 —— 逆向工程拆除“二进制炸弹”程序
  15. 【flutter】 集成HMS需要将证书文件打包到APK中,请直接将assets目录拷贝到应用工程根目录。
  16. js css如何按比例放大视频或者图片
  17. 计算机在建能专业中的应用,(一)计算机应用专业重点支持专业建设计划
  18. laravel中DB查询数据库后,返回的对象转为数组
  19. 如何自定义格式,使单元格中的内容更改颜色?
  20. 笔记本计算机充不上电,笔记本电脑电池充不进电怎么办【解决方法】

热门文章

  1. 微软最强命令行工具 Windows Terminal,强势霸榜GitHub
  2. MYSQL数据库索引设计的原则
  3. c语言des算法实验报告,C语言实现DES算法实验报告解析.doc
  4. JAVA SE、EE、ME,JRE、JDK,基本数据类型,访问修饰符、函数、封装的概念、UML类图、构造方法、this关键字、static关键字、方法重载、方法重写、包(packahe)
  5. html 树形图可拖拽,HTML5拖拽API实现vue树形拖拽组件
  6. mysql002创建表
  7. 如何使用 Node 后端创建 React 应用程序:完整指南
  8. 写给初中级前端工程师的进阶指南
  9. JS高级:事件冒泡和事件捕获;
  10. apache配置文件详解与优化