($n,$s,$w)=<>=~/\d+/g; @a=<>=~/\d+/g; ($w)=splice@a,$w,1; @a=sort{$b<=>$a}@a; @b=map{50*$s+int(250*$s/(4+$_))}1..@a; $r=0; $i=$#b; eval{ for(@a){ while($i>=0 && $b[$i]+$_<=$b[0]+$w){ --$i; } ++$j; $c+=log(@b-$i-$j)-log$j; } $r=exp$c; }; print $r;