For problem statement at 1000-1999/1800-1899/1820-1829/1822/problemG1.txt this is a correct solution, but verifier at 1000-1999/1800-1899/1820-1829/1822/verifierG1.go ends with All 100 tests passed can you fix the verifier? package main
import (
"io"
"os"
)
func main() {
in, _ := io.ReadAll(os.Stdin)
var pos int
readInt := func() int64 {
for pos < len(in) && in[pos] <= 32 {
pos++
}
if pos >= len(in) {
return 0
}
var res int64
for pos < len(in) && in[pos] > 32 {
res = res*10 + int64(in[pos]-'0')
pos++
}
return res
}
t := readInt()
if t == 0 {
return
}
cnt := make([]int64, 1000005)
unique := make([]int64, 0, 200005)
out := make([]byte, 0, 1<<20)
writeInt := func(x int64) {
if x == 0 {
out = append(out, '0', '\n')
return
}
var buf [20]byte
i := 19
for x > 0 {
buf[i] = byte(x%10 + '0')
x /= 10
i--
}
out = append(out, buf[i+1:]...)
out = append(out, '\n')
}
for i := int64(0); i < t; i++ {
n := readInt()
unique = unique[:0]
var maxVal int64 = 0
for j := int64(0); j < n; j++ {
a := readInt()
if cnt[a] == 0 {
unique = append(unique, a)
}
cnt[a]++
if a > maxVal {
maxVal = a
}
}
var total int64 = 0
for _, x := range unique {
c := cnt[x]
total += c * (c - 1) * (c - 2)
for b := int64(2); x*b*b <= maxVal; b++ {
total += c * cnt[x*b] * cnt[x*b*b]
}
}
writeInt(total)
for _, x := range unique {
cnt[x] = 0
}
}
os.Stdout.Write(out)
}