栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

zoj 2918 Pachinko

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

zoj 2918 Pachinko

#include<iostream>#include<cstdio>#include<cstring>#include<cctype>#include<stdio.h>using namespace std;enum {    SIZ = 104,};int H, W;char mat[SIZ][SIZ];double tab[2][SIZ];void fun(){    double *pre=tab[0], *cur=tab[1];    memset(pre, 0, sizeof(tab[0]));    for (int i=H-1; i>=0; --i){        for (int j=0; j<W; ++j){ if (i+1<H && mat[i+1][j] == '*'){     int t = 0;     double v = 0;     if (j!=0){         v += pre[j-1];         ++t;     }     if(j!=W-1){         v += pre[j+1];         ++t;     }     cur[j] = 0;     if (t) cur[j] = v/t; } else {     cur[j] = pre[j]; } if (isdigit(mat[i][j])){     cur[j] = mat[i][j] - '0'; }else if (mat[i][j]=='*'){     cur[j] = 0; }        }        swap(pre, cur);    }    double ans = 0;    for (int i=0; i<W; ++i){        ans = max(pre[i], ans);    }    printf("%.06lfn", ans);}void readIn(){    scanf("%d%d ", &H, &W);    for (int i=0; i<H; ++i){        scanf("%s", mat[i]);    }}int main(){    int tn;    scanf("%d", &tn);    while(tn-- > 0){        readIn();        fun();    }    return 0;}
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/378705.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号