共一行,包含一个正整数 x。含义详见题面。
输出一行一个实数,表示答案。
设ans为期望多少刀暴击一刀,则 1 a n s \frac{1}{ans} ans1就是答案 设exp[i]表示期望i刀暴击1刀 则 a n s = ∑ i = 1 100 x e x p [ i ] ans=\sum_{i=1}^{\frac{100}{x}}exp[i] ans=∑i=1x100exp[i] exp[i]应该很好求 exp[i]的期望应该是i × \times ×(第i刀暴击的概率) × \times ×(第1~i-1刀不暴击的概率) 还不懂的可以看代码
#include <cstdio> #include <algorithm> #define open(x) freopen(x".in","r",stdin);freopen(x".out","w",stdout); using namespace std; int x,pl; long double t,pro,ans; int main() { open("lol"); scanf("%d",&x); pl=1; t=1; pro=x/100.0; while (pro<1) { ans+=pl*t*pro; t*=(1-pro); pro+=x/100.0; pl++; } ans+=pl*t; printf("%.10Lf",1/ans); return 0; }