ll@T;rep(T){double@p;ll@K;wt(p==0?K:(1-(K-(K-1)*(1-p))*(1-p)**(K-1))/p+K*(1-p)**(K-1));} 1p+2(1-p)p+3 sum n(1-p)^{n-1}p+K(1-p)^{K-1} sum q^n = (1-q^K)/(1-q) ->-Kq^{K-1}*(1-q)+(1-qK)/(1-q)^2=(1-Kq^{K-1}+(K-1)q^K)/(1-q)^2 rep(i,N)x+=A[i],wtSp(x); rep[A](a,N)x+=a,wtLn(x); x=sum[ll][i,0,N@iの満たす条件$条件を満たすiがない時の返り値](A[i]); if(OR[i,0,N](A[i]==1))x=1; wt(x);