For problem statement at 0-999/400-499/400-409/407/problemA.txt this is a correct solution, but verifier at 0-999/400-499/400-409/407/verifierA.go ends with case 1 failed: expected YES
0 0
171 228
-516 387 got YES
0 0
387 516
-228 171
input:
645 285
exit status 1 can you fix the verifier? package main
import (
"bufio"
"fmt"
"math"
"os"
)
func gcd(a, b int) int {
for b != 0 {
a, b = b, a%b
}
if a < 0 {
return -a
}
return a
}
func main() {
in := bufio.NewReader(os.Stdin)
out := bufio.NewWriter(os.Stdout)
defer out.Flush()
var a, b int
if _, err := fmt.Fscan(in, &a, &b); err != nil {
return
}
g := gcd(a, b)
found := false
var ax, ay, bx, by int
for c := 1; c <= g && !found; c++ {
if g%c != 0 {
continue
}
cc := c * c
for x := 1; x < c && !found; x++ {
y2 := cc - x*x
if y2 <= 0 {
continue
}
y := int(math.Sqrt(float64(y2)))
if y*y != y2 {
continue
}
m := a / c
n := b / c
// Try orientation 1
ux, uy := m*x, m*y
vx1, vy1 := -n*y, n*x
wy1 := vy1 - uy
if wy1 != 0 {
ax, ay = 0, 0
bx, by = ux, uy
fmt.Fprintln(out, "YES")
fmt.Fprintln(out, ax, ay)
fmt.Fprintln(out, bx, by)
fmt.Fprintln(out, vx1, vy1)
found = true
break
}
// Try orientation 2
vx2, vy2 := n*y, -n*x
wx2 := vx2 - ux
if wx2 != 0 {
ax, ay = 0, 0
bx, by = ux, uy
fmt.Fprintln(out, "YES")
fmt.Fprintln(out, ax, ay)
fmt.Fprintln(out, bx, by)
fmt.Fprintln(out, vx2, vy2)
found = true
break
}
}
}
if !found {
fmt.Fprintln(out, "NO")
}
}