P5104 红包发红包

jennie

运用几何概型的知识可以知道,每个人期望取到的钱是前一个人的一半。

确实如此

#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
#define int long long
int mod=1000000007;
template<class T>

void read(T &now){
    now=0;
    char c=getchar();
    int f=1;#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
#define int long long
int mod=1000000007;
template<class T>

void read(T &now){
    now=0;
    char c=getchar();
    int f=1;
    while((!isdigit(c))){
        if(c=='-') f=-1;
        c=getchar();
    }
    while(isdigit(c)){
        now=(now<<1)+(now<<3)+c-'0';
        c=getchar();
    }
    now*=f;
}
int w,n,k;
int qp(int bas,int mi){
    int ans=1;
    while(mi){
        if(mi&1){
            ans*=bas;
            ans%=mod;
        }
        bas*=bas;
        bas%=mod;
        mi>>=1;
    }
    return ans;
}
signed main(){
    read(w);read(n);read(k);
    int inv=qp(2,mod-2);
    cout<<w*qp(inv,k)%mod;
    return 0;
}
    while((!isdigit(c))){
        if(c=='-') f=-1;
    //  cout<<isdigit(c)<<" "<<c<<" ";
        c=getchar();
    }
    while(isdigit(c)){
        now=(now<<1)+(now<<3)+c-'0';
        c=getchar();
    }
    now*=f;
}
int w,n,k;
int qp(int bas,int mi){
    int ans=1;
    while(mi){
        if(mi&1){
            ans*=bas;
            ans%=mod;
        }
        bas*=bas;
        bas%=mod;
        mi>>=1;
    }
    return ans;
}
signed main(){
    read(w);read(n);read(k);
    int inv=qp(2,mod-2);
    cout<<w*qp(inv,k)%mod;
    return 0;
}
暂无评论

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇