← Home
For problem statement at 0-999/300-399/370-379/374/problemA.txt this is a correct solution, but verifier at 0-999/300-399/370-379/374/verifierA.go ends with All tests passed can you fix the verifier? package main

import (
	"bufio"
	"fmt"
	"os"
)

func abs(x int64) int64 {
	if x < 0 {
		return -x
	}
	return x
}

func main() {
	in := bufio.NewReader(os.Stdin)

	var n, m, i, j, a, b int64
	fmt.Fscan(in, &n, &m, &i, &j, &a, &b)

	corners := [][2]int64{
		{1, 1},
		{1, m},
		{n, 1},
		{n, m},
	}

	const inf int64 = 1 << 60
	ans := inf

	for _, c := range corners {
		dx := abs(c[0] - i)
		dy := abs(c[1] - j)

		if dx%a == 0 && dy%b == 0 {
			px := dx / a
			py := dy / b
			if px%2 == py%2 {
				if px < py {
					px = py
				}
				if px < ans {
					ans = px
				}
			}
		}
	}

	if ans == 0 {
		fmt.Println(0)
		return
	}

	canX := i-a >= 1 || i+a <= n
	canY := j-b >= 1 || j+b <= m

	if ans == inf || !canX || !canY {
		fmt.Println("Poor Inna and pony!")
	} else {
		fmt.Println(ans)
	}
}