// No.1992 Tendon Walk package main import ( "fmt" "math" ) func main() { var x int fmt.Scan(&x) const a = 2 const b = -1 set := []int{a, a, b, b, a, b, b} pos, ans := 0, 0.0 for { for _, v := range set { pos += v ans += math.Abs(float64(v)) if pos == x { goto Exit } } } Exit: fmt.Println(ans) }