zoukankan      html  css  js  c++  java
  • 【BZOJ2134】单位错选(数学期望,动态规划)

    【BZOJ2134】单位错选(数学期望,动态规划)

    题面

    BZOJ

    题解

    单独考虑相邻的两道题目的概率就好了

    没了呀。。

    #include<iostream>
    #include<cstdio>
    #include<cstdlib>
    #include<cstring>
    #include<cmath>
    #include<algorithm>
    #include<set>
    #include<map>
    #include<vector>
    #include<queue>
    using namespace std;
    #define ll long long
    #define RG register
    inline int read()
    {
        RG int x=0,t=1;RG char ch=getchar();
        while((ch<'0'||ch>'9')&&ch!='-')ch=getchar();
        if(ch=='-')t=-1,ch=getchar();
        while(ch<='9'&&ch>='0')x=x*10+ch-48,ch=getchar();
        return x*t;
    }
    double ans;
    int a[10000002],n,A,B,C;
    int main()
    {
        n=read();A=read();B=read();C=read();a[1]=read();
        for(int i=2;i<=n;++i)a[i]=(1ll*a[i-1]*A%100000001+B)%100000001;
        for(int i=1;i<=n;++i)a[i]=a[i]%C+1;a[n+1]=a[1];
        for(int i=1;i<=n;++i)ans+=1.0/max(a[i],a[i+1]);
        printf("%.3lf
    ",ans);
        return 0;
    }
    
    
  • 相关阅读:
    Server Profiler
    Unit Test with VS.NET
    js解析json字符
    多维数组
    $routeProvider与$stateProvider区别
    post 与get
    gulp配置
    homebrew常用指令
    less.js
    过滤器
  • 原文地址:https://www.cnblogs.com/cjyyb/p/8435982.html
Copyright © 2011-2022 走看看