← Home
For problem statement at 0-999/400-499/450-459/457/problemD.txt this is a correct solution, but verifier at 0-999/400-499/450-459/457/verifierD.go ends with case 1 failed:
input:1 1 0
expected:1.000000000000000
actual:1
exit status 1 can you fix the verifier? package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	in := bufio.NewReaderSize(os.Stdin, 1<<20)
	out := bufio.NewWriterSize(os.Stdout, 1<<20)
	defer out.Flush()

	var n, m, k int
	fmt.Fscan(in, &n, &m, &k)

	comb := make([]float64, n+1)
	comb[0] = 1
	for i := 0; i < n; i++ {
		comb[i+1] = comb[i] * float64(n-i) / float64(i+1)
	}

	maxT := n * n
	if k < maxT {
		maxT = k
	}
	p := make([]float64, maxT+1)
	p[0] = 1
	for t := 0; t < maxT; t++ {
		p[t+1] = p[t] * float64(k-t) / float64(m-t)
	}

	const capVal = 1e99
	sum := 0.0
	comp := 0.0

	for a := 0; a <= n; a++ {
		ca := comb[a]
		for b := 0; b <= n; b++ {
			t := n*(a+b) - a*b
			if t > k {
				continue
			}
			term := ca * comb[b] * p[t]
			y := term - comp
			tmp := sum + y
			comp = (tmp - sum) - y
			sum = tmp
		}
	}

	if sum >= capVal {
		fmt.Fprintln(out, "1e99")
	} else {
		fmt.Fprintf(out, "%.15g\n", sum)
	}
}