結果

問題 No.575 n! / m / m / m...
ユーザー char134217728
提出日時 2017-12-18 03:14:44
言語 Ruby
(3.4.1)
結果
WA  
実行時間 -
コード長 367 bytes
コンパイル時間 260 ms
コンパイル使用メモリ 7,552 KB
実行使用メモリ 12,544 KB
最終ジャッジ日時 2024-07-19 16:22:59
合計ジャッジ時間 5,008 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 11 WA * 12
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

n, m = gets.split.map &:to_i
ans = if n > 10000
  c = 0
  _m = m
  while n >= _m
    c += n / _m
    _m *= m
  end
  ln = Math.log10(n)
  n * (ln - Math.log10(Math::E)) + (ln + Math.log10(Math::PI) + Math.log10(2))/2 - c * Math.log10(m)
else
  f = [*1..n].inject :*
  while f%m == 0
    f /= m
  end
  Math.log10 f
end
a = ans.floor
b = ans % 1
puts "#{10.0**b}e#{a}"
0