For problem statement at 2000-2999/2100-2199/2160-2169/2167/problemD.txt this is a correct solution, but verifier at 2000-2999/2100-2199/2160-2169/2167/verifierD.go ends with All 20 tests passed. can you fix the verifier? package main
import (
"bufio"
"os"
"strconv"
)
func gcd(a, b int64) int64 {
for b != 0 {
a, b = b, a%b
}
return a
}
func main() {
scanner := bufio.NewScanner(os.Stdin)
scanner.Split(bufio.ScanWords)
out := bufio.NewWriter(os.Stdout)
defer out.Flush()
scanInt := func() int64 {
scanner.Scan()
val, _ := strconv.ParseInt(scanner.Text(), 10, 64)
return val
}
if !scanner.Scan() {
return
}
t, _ := strconv.Atoi(scanner.Text())
primes := []int64{2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53}
for tc := 0; tc < t; tc++ {
n := int(scanInt())
var g int64
for i := 0; i < n; i++ {
a := scanInt()
if i == 0 {
g = a
} else {
g = gcd(g, a)
}
}
for _, p := range primes {
if g%p != 0 {
out.WriteString(strconv.FormatInt(p, 10) + "\n")
break
}
}
}
}