For problem statement at 0-999/600-699/660-669/665/problemD.txt this is a correct solution, but verifier at 0-999/600-699/660-669/665/verifierD.go ends with All tests passed can you fix the verifier? package main
import (
"bufio"
"fmt"
"os"
"strconv"
"strings"
)
func isPrime(n int) bool {
if n < 2 {
return false
}
if n == 2 || n == 3 {
return true
}
if n%2 == 0 || n%3 == 0 {
return false
}
for i := 5; i*i <= n; i += 6 {
if n%i == 0 || n%(i+2) == 0 {
return false
}
}
return true
}
func main() {
scanner := bufio.NewScanner(os.Stdin)
scanner.Split(bufio.ScanWords)
if !scanner.Scan() {
return
}
n, _ := strconv.Atoi(scanner.Text())
a := make([]int, n)
ones := 0
for i := 0; i < n; i++ {
scanner.Scan()
a[i], _ = strconv.Atoi(scanner.Text())
if a[i] == 1 {
ones++
}
}
ans1 := []int{}
if ones > 0 {
for i := 0; i < ones; i++ {
ans1 = append(ans1, 1)
}
for _, x := range a {
if x != 1 && isPrime(x+1) {
ans1 = append(ans1, x)
break
}
}
}
ans2 := []int{}
for i := 0; i < n; i++ {
for j := i + 1; j < n; j++ {
if isPrime(a[i] + a[j]) {
ans2 = []int{a[i], a[j]}
break
}
}
if len(ans2) > 0 {
break
}
}
ans3 := []int{a[0]}
res := ans1
if len(ans2) > len(res) {
res = ans2
}
if len(ans3) > len(res) {
res = ans3
}
fmt.Println(len(res))
strRes := make([]string, len(res))
for i, x := range res {
strRes[i] = strconv.Itoa(x)
}
fmt.Println(strings.Join(strRes, " "))
}