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);
        }
    }


  • 相关阅读:
    安卓android.support.design使用中的问题
    处理requests SSl 证书问题
    python-excel
    post 请求包含相同参数
    关于zk 页面滚动问题 scroll
    Usefull Jquery
    Git 安装
    Comparison issues in TD
    Work Diary 12/13/17
    Unit10 I don't like work in the weekend
  • 原文地址:https://www.cnblogs.com/Stomach-ache/p/3703211.html
Copyright © 2011-2022 走看看