题解 | #记负均正II#
记负均正II
http://www.nowcoder.com/practice/64f6f222499c4c94b338e588592b6a62
很简单的一道模拟,求平均的时候注意采样。
import sys
cnt1, cnt2, res = 0, 0, 0.0
for line in sys.stdin:
n = float(line)
if n < 0: cnt1 += 1
else:
cnt2 += 1
res = (res*(cnt2-1)+n)/cnt2
print(cnt1)
print(round(res,1))