From 3c505ffddfaeec7f5ce4fa01581daad7fd3c3b33 Mon Sep 17 00:00:00 2001 From: Baoshuo Date: Wed, 8 Jun 2022 16:08:11 +0800 Subject: [PATCH] =?UTF-8?q?#6.=20=E7=8C=9C=E6=95=B0=E5=AD=97=202?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://loj.ac/s/1478192 --- LibreOJ/6/6.go | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 LibreOJ/6/6.go diff --git a/LibreOJ/6/6.go b/LibreOJ/6/6.go new file mode 100644 index 00000000..00c17f00 --- /dev/null +++ b/LibreOJ/6/6.go @@ -0,0 +1,38 @@ +package main + +import "fmt" + +func main() { + var n int + var ans [105]int + + fmt.Println("get_num") + fmt.Scan(&n) + + for i := 0; i < n; i++ { + l, r := 1, 1000000 + + for l <= r { + mid := (l + r) >> 1 + fmt.Println("guess", i, mid) + + var res int + fmt.Scan(&res) + + if res == 0 { + ans[i] = mid + break + } else if res > 0 { + r = mid - 1 + } else { // res < 0 + l = mid + 1 + } + } + } + + fmt.Print("submit ") + for i := 0; i < n; i++ { + fmt.Printf("%d ", ans[i]) + } + fmt.Printf("\n") +}