zoukankan      html  css  js  c++  java
  • Luogu5104 红包发红包 (期望)

    曾几何时有人说概率期望easy。。。

    显然,期望是(frac{w}{2^n})

    #include <iostream>
    #include <cstdio>
    #include <cstring>
    #include <algorithm>
    #include <cmath>
    #define R(a,b,c) for(register int  a = (b); a <= (c); ++ a)
    #define nR(a,b,c) for(register int  a = (b); a >= (c); -- a)
    #define Max(a,b) ((a) > (b) ? (a) : (b))
    #define Min(a,b) ((a) < (b) ? (a) : (b))
    #define Fill(a,b) memset(a, b, sizeof(a))
    #define Abs(a) ((a) < 0 ? -(a) : (a))
    #define Swap(a,b) a^=b^=a^=b
    #define ll long long
    
    #define ON_DEBUG
    
    #ifdef ON_DEBUG
    
    #define D_e_Line printf("
    
    ----------
    
    ")
    #define D_e(x)  cout << #x << " = " << x << endl
    #define Pause() system("pause")
    #define FileOpen() freopen("in.txt","r",stdin);
    
    #else
    
    #define D_e_Line ;
    #define D_e(x)  ;
    #define Pause() ;
    #define FileOpen() ;
    
    #endif
    
    struct ios{
        template<typename ATP>ios& operator >> (ATP &x){
            x = 0; int f = 1; char c;
            for(c = getchar(); c < '0' || c > '9'; c = getchar()) if(c == '-')  f = -1;
            while(c >= '0' && c <= '9') x = x * 10 + (c ^ '0'), c = getchar();
            x*= f;
            return *this;
        }
    }io;
    using namespace std;
    
    const int mod = 1e9 + 7; 
    
    inline long long Pow(long long a, long long b){
    	long long s = 1;
    	while(b){
    		if(b & 1) s = s * a % mod;
    		a = a * a % mod, b >>= 1; 
    	}
    	return s;
    }
    int main(){
    	long long n, xxx, w;
    	io >> w >> xxx >> n;
    	
    	printf("%lld", w * Pow(Pow(2, n), mod - 2) % mod);
    	
    	return 0;
    }
    

  • 相关阅读:
    CF1284G
    5-3 Harbor高可用部署 下
    5业务系统迁移kubernetes-----准备工作(平稳迁移做好准备)
    题解-CF1453F Even Harder
    题解-CF961F k-substrings
    Docker 数据卷容器(实现两个或多个容器间数据同步)
    Docker 具名和匿名挂载
    Java-IO中的节点流和处理流
    《机器学习十讲》学习报告二
    rpc基本思路
  • 原文地址:https://www.cnblogs.com/bingoyes/p/11244576.html
Copyright © 2011-2022 走看看