Balls(概率)

Balls

https://ac.nowcoder.com/acm/problem/20709

本题从概率出发计算期望,用不到dp,因为白球和黑球完全公平,取1次即期望+0.5:

#include <cmath>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <set>
#include <stack>
#include <stdio.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9;
const int maxn = 1e7;

int main(){
    int n;
    cin >> n;
    cout << 1+n/2;
    if(n&1) cout << ".5000000";
    else cout << ".0000000";
}
全部评论

相关推荐

点赞 评论 收藏
分享
评论
3
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务