結果

問題 No.575 n! / m / m / m...
ユーザー char134217728char134217728
提出日時 2017-12-18 03:14:44
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 367 bytes
コンパイル時間 95 ms
コンパイル使用メモリ 11,432 KB
実行使用メモリ 16,092 KB
最終ジャッジ日時 2023-09-26 22:37:31
合計ジャッジ時間 5,495 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 92 ms
15,592 KB
testcase_01 AC 84 ms
15,432 KB
testcase_02 AC 84 ms
15,432 KB
testcase_03 AC 84 ms
15,448 KB
testcase_04 AC 82 ms
15,520 KB
testcase_05 AC 86 ms
16,092 KB
testcase_06 AC 83 ms
15,488 KB
testcase_07 AC 84 ms
15,384 KB
testcase_08 AC 84 ms
15,648 KB
testcase_09 AC 84 ms
15,276 KB
testcase_10 AC 83 ms
15,388 KB
testcase_11 AC 82 ms
15,604 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 85 ms
15,452 KB
testcase_24 WA -
testcase_25 AC 83 ms
15,428 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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