package main import ( "bufio" "fmt" "os" "strconv" "strings" ) // エントリポイント func main() { in := bufio.NewScanner(os.Stdin) // ポッキーの長さと、1回にかじるポッキーの長さ in.Scan() input1 := in.Text() fmt.Println(pocky(input1)) } func pocky(str string) string { sp := strings.Split(str, " ") // ポッキーの長さ pockyLength, _ := strconv.Atoi(sp[0]) // 1回に齧るポッキーの長さ gnawLength, _ := strconv.Atoi(sp[1]) res := pockyLength / (gnawLength * 2) if pockyLength % (gnawLength * 2) == 0 && res != 0 { // ちょうど割り切れた場合はかじるのをやめるため、-1 res-- } res *= gnawLength return strconv.Itoa(res) }