結果

問題 No.1042 愚直大学
ユーザー c-yan
提出日時 2020-05-01 22:31:14
言語 Go
(1.23.4)
結果
TLE  
実行時間 -
コード長 861 bytes
コンパイル時間 10,577 ms
コンパイル使用メモリ 234,604 KB
実行使用メモリ 13,764 KB
最終ジャッジ日時 2024-12-25 13:07:02
合計ジャッジ時間 26,726 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 18 TLE * 5
権限があれば一括ダウンロードができます

ソースコード

diff #

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
}
0