zoukankan      html  css  js  c++  java
  • HDU 4576 Robot

    //题目并不算难,但是特么的就是坑死你。。。

    //用数组a[]维护每轮的结果,a[i]就是代表走到i的概率。。。还需借助辅助数组q[]。

    #include<stdio.h>

    #include<string.h>
    #define max 205

    int n,m,l,r;
    double q[max],a[max];

    int main(){
        while(scanf("%d%d%d%d",&n,&m,&l,&r)==4,n+m+l+r){
            memset(a,0,sizeof(a));
            memset(q,0,sizeof(q));
            a[1]=1;
            for(int j=0;j<m;j++){
                int w;
                scanf("%d",&w);
                w%=n;
                //memset(q,0,sizeof(q));
                for(int i=1;i<=n;i++){
                    if(a[i]==0){
                        continue;
                    }
                    int rr=i+w;
                    while(rr>n){
                        rr-=n;
                    }
                    q[rr]+=a[i]*0.5;
                    int ll=i-w;
                    while(ll<=0){
                        ll+=n;
                    }
                    q[ll]+=a[i]*0.5;
                }
                memcpy(a,q,sizeof(q));
                memset(q,0,sizeof(q));
            }
            double ans=0;
            for(int i=l;i<=r;i++){
                ans+=a[i];
            }
            printf("%.4lf ",ans);
        }
    }


  • 相关阅读:
    easycom HBuilderX 2.5.5起支持easycom组件模式
    我们为什么需要async/await ?
    封装uni.request请求
    uniapp 更新
    uniapp中plus的使用
    uniapp 自适应不同比例的屏幕
    npm 设置淘宝镜像、nrm、nodemon
    uniapp之nvue入坑
    Android平台签名证书(.keystore)生成指南
    day 37 数据库MySQL的进一步认识
  • 原文地址:https://www.cnblogs.com/Stomach-ache/p/3703211.html
Copyright © 2011-2022 走看看