結果

問題 No.1042 愚直大学
ユーザー nadeshinonadeshino
提出日時 2020-05-01 22:04:46
言語 Nim
(2.2.0)
結果
WA  
実行時間 -
コード長 475 bytes
コンパイル時間 4,771 ms
コンパイル使用メモリ 64,984 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-12-25 10:38:36
合計ジャッジ時間 5,942 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
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 .. 1000000:
  var mid = (ok + ng) / 2.0
  if f(mid) <= 0.0:
    ok = mid
  else:
    ng = mid
echo ok
0