For problem statement at 1000-1999/1200-1299/1290-1299/1292/problemB.txt this is a correct solution, but verifier at 1000-1999/1200-1299/1290-1299/1292/verifierB.go ends with all tests passed can you fix the verifier? package main
import (
"bufio"
"fmt"
"os"
)
type Point struct {
x int64
y int64
}
func abs(a int64) int64 {
if a < 0 {
return -a
}
return a
}
func nextVal(v, a, b, limit int64) int64 {
if b > limit {
return limit + 1
}
if v > (limit-b)/a {
return limit + 1
}
return v*a + b
}
func main() {
in := bufio.NewReader(os.Stdin)
var x0, y0, ax, ay, bx, by int64
var xs, ys, t int64
fmt.Fscan(in, &x0, &y0, &ax, &ay, &bx, &by)
fmt.Fscan(in, &xs, &ys, &t)
xLimit := xs + t
yLimit := ys + t
points := make([]Point, 0)
x, y := x0, y0
for x <= xLimit && y <= yLimit {
points = append(points, Point{x, y})
x = nextVal(x, ax, bx, xLimit)
y = nextVal(y, ay, by, yLimit)
}
n := len(points)
ans := 0
for l := 0; l < n; l++ {
for r := l; r < n; r++ {
segment := (points[r].x - points[l].x) + (points[r].y - points[l].y)
dsL := abs(xs-points[l].x) + abs(ys-points[l].y)
dsR := abs(xs-points[r].x) + abs(ys-points[r].y)
cost := segment + dsL
if dsR < dsL {
cost = segment + dsR
}
if cost <= t && r-l+1 > ans {
ans = r - l + 1
}
}
}
fmt.Println(ans)
}