For problem statement at 1000-1999/1800-1899/1820-1829/1822/problemG2.txt this is a correct solution, but verifier at 1000-1999/1800-1899/1820-1829/1822/verifierG2.go ends with All tests passed can you fix the verifier? package main
import (
"io"
"math"
"os"
"strconv"
)
type FastScanner struct {
data []byte
idx int
n int
}
func NewFastScanner() *FastScanner {
data, _ := io.ReadAll(os.Stdin)
return &FastScanner{data: data, n: len(data)}
}
func (fs *FastScanner) NextInt() int {
for fs.idx < fs.n {
c := fs.data[fs.idx]
if c >= '0' && c <= '9' {
break
}
fs.idx++
}
v := 0
for fs.idx < fs.n {
c := fs.data[fs.idx]
if c < '0' || c > '9' {
break
}
v = v*10 + int(c-'0')
fs.idx++
}
return v
}
func main() {
fs := NewFastScanner()
t := fs.NextInt()
out := make([]byte, 0, t*24)
for ; t > 0; t-- {
n := fs.NextInt()
freq := make(map[int]int64, n*2)
keys := make([]int, 0, n)
maxVal := 0
for i := 0; i < n; i++ {
v := fs.NextInt()
if _, ok := freq[v]; !ok {
keys = append(keys, v)
}
freq[v]++
if v > maxVal {
maxVal = v
}
}
var ans int64
for _, x := range keys {
c := freq[x]
ans += c * (c - 1) * (c - 2)
}
for _, x := range keys {
val := maxVal / x
if val < 4 {
continue
}
limit := int(math.Sqrt(float64(val)))
for (limit+1)*(limit+1) <= val {
limit++
}
for limit*limit > val {
limit--
}
fx := freq[x]
for b := 2; b <= limit; b++ {
y := x * b
fy := freq[y]
if fy == 0 {
continue
}
z := y * b
fz := freq[z]
if fz == 0 {
continue
}
ans += fx * fy * fz
}
}
out = strconv.AppendInt(out, ans, 10)
out = append(out, '\n')
}
_, _ = os.Stdout.Write(out)
}