結果

問題 No.1042 愚直大学
ユーザー nadeshino
提出日時 2020-05-01 21:42:08
言語 Nim
(2.2.0)
結果
WA  
実行時間 -
コード長 472 bytes
コンパイル時間 3,608 ms
コンパイル使用メモリ 65,108 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-12-25 02:03:09
合計ジャッジ時間 4,404 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 15 WA * 8
権限があれば一括ダウンロードができます

ソースコード

diff #

import math, strutils

let read* = iterator: string =
  while true: (for s in stdin.readLine.split: yield s)

template input*(T: static[typedesc]): untyped = 
  when T is int: read().parseInt
  elif T is float: read().parseFloat
  elif T is string: read()

let P, Q = input(float)
proc f(N: float): float =
  N * N - Q * N * log2(N) - P
var ok = 1.0
var ng = 1e9
for _ in 1 .. 1000:
  var mid = (ok + ng) / 2.0
  if f(mid) <= 0.0:
    ok = mid
  else:
    ng = mid
echo ok
0