結果

問題 No.575 n! / m / m / m...
ユーザー 0w10w1
提出日時 2017-11-03 21:47:37
言語 Ruby
(3.3.0)
結果
AC  
実行時間 193 ms / 2,000 ms
コード長 361 bytes
コンパイル時間 111 ms
コンパイル使用メモリ 11,504 KB
実行使用メモリ 15,856 KB
最終ジャッジ日時 2023-08-14 16:49:24
合計ジャッジ時間 4,165 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 91 ms
15,540 KB
testcase_01 AC 89 ms
15,624 KB
testcase_02 AC 88 ms
15,664 KB
testcase_03 AC 88 ms
15,700 KB
testcase_04 AC 89 ms
15,652 KB
testcase_05 AC 89 ms
15,652 KB
testcase_06 AC 88 ms
15,460 KB
testcase_07 AC 89 ms
15,780 KB
testcase_08 AC 90 ms
15,560 KB
testcase_09 AC 86 ms
15,560 KB
testcase_10 AC 89 ms
15,784 KB
testcase_11 AC 88 ms
15,732 KB
testcase_12 AC 89 ms
15,580 KB
testcase_13 AC 89 ms
15,580 KB
testcase_14 AC 90 ms
15,628 KB
testcase_15 AC 90 ms
15,648 KB
testcase_16 AC 89 ms
15,752 KB
testcase_17 AC 89 ms
15,696 KB
testcase_18 AC 92 ms
15,604 KB
testcase_19 AC 89 ms
15,756 KB
testcase_20 AC 90 ms
15,696 KB
testcase_21 AC 91 ms
15,808 KB
testcase_22 AC 88 ms
15,856 KB
testcase_23 AC 193 ms
15,680 KB
testcase_24 AC 89 ms
15,652 KB
testcase_25 AC 193 ms
15,648 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

require 'prime'
N, M = gets.split.map &:to_i
pes = Prime.prime_division(M)
k = pes.map { |pe| 
  f = lambda do |n, p|
    r = 0
    z = p
    until n < p
      r += n / p
      p *= z
    end
    r
  end
  f[N, pe[0]] / pe[1]
} .min
log10ans = Math.lgamma(N + 1)[0] / Math.log(10) - k * Math.log10(M)
puts "#{10 ** (log10ans - log10ans.to_i)}e#{log10ans.to_i}"
0