結果

問題 No.140 みんなで旅行
ユーザー cielciel
提出日時 2015-05-28 00:00:34
言語 Ruby
(3.3.0)
結果
AC  
実行時間 308 ms / 5,000 ms
コード長 340 bytes
コンパイル時間 84 ms
コンパイル使用メモリ 11,448 KB
実行使用メモリ 22,616 KB
最終ジャッジ日時 2023-09-20 17:00:48
合計ジャッジ時間 4,002 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 84 ms
15,148 KB
testcase_01 AC 77 ms
15,284 KB
testcase_02 AC 91 ms
15,892 KB
testcase_03 AC 79 ms
15,116 KB
testcase_04 AC 78 ms
15,164 KB
testcase_05 AC 77 ms
15,160 KB
testcase_06 AC 76 ms
15,148 KB
testcase_07 AC 76 ms
15,340 KB
testcase_08 AC 77 ms
15,112 KB
testcase_09 AC 77 ms
15,284 KB
testcase_10 AC 77 ms
15,232 KB
testcase_11 AC 306 ms
22,580 KB
testcase_12 AC 88 ms
15,768 KB
testcase_13 AC 83 ms
15,284 KB
testcase_14 AC 308 ms
22,616 KB
testcase_15 AC 307 ms
22,612 KB
testcase_16 AC 167 ms
17,960 KB
testcase_17 AC 121 ms
17,204 KB
testcase_18 AC 257 ms
20,940 KB
testcase_19 AC 276 ms
21,588 KB
testcase_20 AC 115 ms
16,952 KB
testcase_21 AC 80 ms
15,156 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

#!/usr/bin/ruby
N=gets.to_i
M=10**9+7
C,F,P=3.times.map{(N+2).times.map{[0]*(N+2)}}
(0..N).each{|x|
	C[x][0]=F[x][1]=1
	(1..x).each{|y|C[x][y]=(C[x-1][y]+C[x-1][y-1])%M;F[x][y]=(F[x-1][y-1]+y*F[x-1][y])%M}
}
r=0
(0..N).each{|x|
	P[x][0]=1
	(0..N).each{|y|P[x][y+1]=P[x][y]*x*~-x%M}
	(0..N).each{|y|r=(r+C[N][N-y]*F[N-y][x]*P[x][y])%M}
}
p r
0