結果

問題 No.573 a^2[i] = a[i]
ユーザー 0w10w1
提出日時 2017-11-03 22:30:22
言語 Ruby
(3.3.0)
結果
AC  
実行時間 1,716 ms / 2,000 ms
コード長 219 bytes
コンパイル時間 67 ms
コンパイル使用メモリ 11,556 KB
実行使用メモリ 38,652 KB
最終ジャッジ日時 2023-08-14 16:57:57
合計ジャッジ時間 8,792 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 88 ms
20,124 KB
testcase_01 AC 89 ms
20,356 KB
testcase_02 AC 88 ms
20,324 KB
testcase_03 AC 89 ms
20,144 KB
testcase_04 AC 89 ms
20,060 KB
testcase_05 AC 89 ms
20,048 KB
testcase_06 AC 89 ms
20,128 KB
testcase_07 AC 90 ms
20,200 KB
testcase_08 AC 88 ms
20,048 KB
testcase_09 AC 88 ms
20,188 KB
testcase_10 AC 90 ms
20,152 KB
testcase_11 AC 87 ms
20,364 KB
testcase_12 AC 88 ms
20,368 KB
testcase_13 AC 92 ms
20,344 KB
testcase_14 AC 92 ms
20,344 KB
testcase_15 AC 89 ms
20,312 KB
testcase_16 AC 88 ms
20,124 KB
testcase_17 AC 89 ms
20,332 KB
testcase_18 AC 89 ms
20,068 KB
testcase_19 AC 87 ms
20,116 KB
testcase_20 AC 90 ms
20,236 KB
testcase_21 AC 89 ms
20,176 KB
testcase_22 AC 87 ms
20,072 KB
testcase_23 AC 89 ms
20,244 KB
testcase_24 AC 88 ms
20,124 KB
testcase_25 AC 98 ms
20,204 KB
testcase_26 AC 89 ms
20,340 KB
testcase_27 AC 88 ms
20,132 KB
testcase_28 AC 88 ms
20,180 KB
testcase_29 AC 89 ms
20,228 KB
testcase_30 AC 91 ms
20,052 KB
testcase_31 AC 90 ms
20,176 KB
testcase_32 AC 91 ms
20,108 KB
testcase_33 AC 96 ms
20,436 KB
testcase_34 AC 99 ms
20,580 KB
testcase_35 AC 102 ms
20,648 KB
testcase_36 AC 103 ms
20,792 KB
testcase_37 AC 102 ms
20,956 KB
testcase_38 AC 103 ms
20,752 KB
testcase_39 AC 117 ms
20,980 KB
testcase_40 AC 116 ms
20,956 KB
testcase_41 AC 120 ms
21,188 KB
testcase_42 AC 134 ms
21,000 KB
testcase_43 AC 135 ms
20,868 KB
testcase_44 AC 165 ms
21,332 KB
testcase_45 AC 243 ms
22,128 KB
testcase_46 AC 1,716 ms
38,652 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

require 'openssl'
N = gets.to_i
M = 10 ** 9 + 7
F = [1]
1.upto(N) do |i|
  F << F[-1] * i % M
end
puts (1..N).map { |i|
  i.to_bn.mod_exp(N - i, M) * F[N] * (F[i] * F[N - i]).to_bn.mod_exp(M - 2, M)  
} .reduce(:+) % M
0