首页 > 其他分享 >2022 ICPC合肥 B Genshin Impact

2022 ICPC合肥 B Genshin Impact

时间:2022-11-21 00:11:18浏览次数:152  
标签:Impact pp 射箭 2022 ans Genshin include

Problem B. Genshin Impact

概率

考虑一段 \(y\) 中,被燃烧的时间段及其概率

只需要计算会影响到这一段的射箭点燃火的概率即可

也就是这一段 \(y\) 开头的那次射箭,以及上次射箭(如果有可能导致燃烧的话),上上次射箭,上上上次射箭.....

听说会有精度问题?还好赛中直接让队友输出 \(20\) 位小数

队友的代码

现在鼠标垫还是必胜客安柏鼠标垫捏

#include <iostream>
#include <cstring>
#include <string>
#include <cstdio>
#include <map>
using namespace std;

int main()
{
    int t;
    scanf("%d", &t);
    while(t--)
    {
        double x, y, p, ans = 0;
        scanf("%lf%lf%lf", &x, &y, &p);
        double pp = 1.0 / p;
        for(double i=0; i+x>0; i-=y)
        {
            ans += min(y, x+i) * pp;
            pp *= (p-1) / p;
        }
        ans /= y;
        printf("%.20f\n", ans);
    }
    return 0;
}

标签:Impact,pp,射箭,2022,ans,Genshin,include
From: https://www.cnblogs.com/dgsvygd/p/16910103.html

相关文章