package main import ( "bufio" "fmt" "math" "os" "strconv" ) func main() { P := readInt() Q := readInt() isOk := func(N float64) bool { return N <= float64(Q)*math.Log2(N)+float64(P)/N } ok := 1 ng := math.MaxInt64 for ng-ok != 1 { m := ok + (ng-ok)/2 if isOk(float64(m)) { ok = m } else { ng = m } } t := float64(ok) e := 1 / math.Pow(2, 20) for isOk(t) { t += e } fmt.Println(t - e) } const ( ioBufferSize = 1 * 1024 * 1024 // 1 MB ) var stdinScanner = func() *bufio.Scanner { result := bufio.NewScanner(os.Stdin) result.Buffer(make([]byte, ioBufferSize), ioBufferSize) result.Split(bufio.ScanWords) return result }() func readString() string { stdinScanner.Scan() return stdinScanner.Text() } func readInt() int { result, err := strconv.Atoi(readString()) if err != nil { panic(err) } return result }