牛客-长沙理工校赛C-取手机

传送门:https://www.nowcoder.com/acm/contest/96/C

参考:http://www.cnblogs.com/Dillonh/p/8835074.html

题意:

durong有a台iphonex和b台s8,并且放在一个保险箱里,durong现在一台一台从保险箱随机拿出这些手机,现在他想知道第k次拿出s8的概率是多少。

思路:

这道题的数学推到真的是惊奇呀。

由此就可以发现结果和K无关,只与a,b有关;

#include <cstdio>
using namespace std;

typedef long long ll;

int main(){
    int t;
    scanf("%d",&t);
    while(t--)
    {
        int a,b,k;
        scanf("%d%d%d",&a,&b,&k);
        ll tmp = a+b;
        double ans = b*1.0/tmp;
        printf("%.3f
",ans);  
    }
    return 0;
}
原文地址:https://www.cnblogs.com/ckxkexing/p/8835571.html