mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-12-24 03:31:59 +00:00
parent
7166536294
commit
3c505ffddf
38
LibreOJ/6/6.go
Normal file
38
LibreOJ/6/6.go
Normal 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")
|
||||
}
|
Loading…
Reference in New Issue
Block a user