結果

問題 No.2326 Factorial to the Power of Factorial to the...
ユーザー i39i39
提出日時 2023-05-28 14:48:18
言語 Ruby
(3.3.0)
結果
AC  
実行時間 130 ms / 2,000 ms
コード長 199 bytes
コンパイル時間 43 ms
コンパイル使用メモリ 11,472 KB
実行使用メモリ 15,340 KB
最終ジャッジ日時 2023-08-27 10:37:03
合計ジャッジ時間 3,394 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 83 ms
15,340 KB
testcase_01 AC 130 ms
15,044 KB
testcase_02 AC 95 ms
15,140 KB
testcase_03 AC 118 ms
14,976 KB
testcase_04 AC 108 ms
15,156 KB
testcase_05 AC 101 ms
15,336 KB
testcase_06 AC 113 ms
15,144 KB
testcase_07 AC 127 ms
15,116 KB
testcase_08 AC 128 ms
15,228 KB
testcase_09 AC 127 ms
15,156 KB
testcase_10 AC 86 ms
15,148 KB
testcase_11 AC 91 ms
15,204 KB
testcase_12 AC 84 ms
15,248 KB
testcase_13 AC 103 ms
15,276 KB
testcase_14 AC 120 ms
15,084 KB
testcase_15 AC 86 ms
15,088 KB
testcase_16 AC 81 ms
15,180 KB
testcase_17 AC 123 ms
15,116 KB
testcase_18 AC 97 ms
15,180 KB
testcase_19 AC 85 ms
15,084 KB
testcase_20 AC 78 ms
14,984 KB
testcase_21 AC 79 ms
15,256 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

n,p=gets.split.map(&:to_i)
mod=10**9+7
s=0
(1..nil).each do |i|
  break if n<p**i
  s+=n/(p**i)
end
nd=1
(1..n).each do |i|
  nd=nd*i%mod
end
(1..n).each do |i|
  nd=nd.pow(i,mod)
end
puts (s*nd)%mod
0