0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-23 19:28:48 +00:00

#6. 猜数字 2

https://loj.ac/s/1478192
This commit is contained in:
Baoshuo Ren 2022-06-08 16:08:11 +08:00
parent 7166536294
commit 3c505ffddf
Signed by: baoshuo
GPG Key ID: 70F90A673FB1AB68

38
LibreOJ/6/6.go Normal file
View File

@ -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")
}