結果

問題 No.1331 Moving Penguin
ユーザー yuruhiyayuruhiya
提出日時 2021-01-09 18:36:13
言語 Crystal
(1.11.2)
結果
AC  
実行時間 516 ms / 1,500 ms
コード長 353 bytes
コンパイル時間 12,577 ms
コンパイル使用メモリ 294,224 KB
実行使用メモリ 10,496 KB
最終ジャッジ日時 2024-04-25 05:06:56
合計ジャッジ時間 34,908 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
5,248 KB
testcase_01 AC 4 ms
5,248 KB
testcase_02 AC 3 ms
5,376 KB
testcase_03 AC 4 ms
5,376 KB
testcase_04 AC 502 ms
10,240 KB
testcase_05 AC 503 ms
9,216 KB
testcase_06 AC 498 ms
9,216 KB
testcase_07 AC 506 ms
9,216 KB
testcase_08 AC 498 ms
8,704 KB
testcase_09 AC 491 ms
8,704 KB
testcase_10 AC 499 ms
8,704 KB
testcase_11 AC 492 ms
8,704 KB
testcase_12 AC 501 ms
8,704 KB
testcase_13 AC 499 ms
8,704 KB
testcase_14 AC 505 ms
8,704 KB
testcase_15 AC 494 ms
8,704 KB
testcase_16 AC 503 ms
8,704 KB
testcase_17 AC 505 ms
8,704 KB
testcase_18 AC 496 ms
8,576 KB
testcase_19 AC 497 ms
8,704 KB
testcase_20 AC 507 ms
8,704 KB
testcase_21 AC 497 ms
8,704 KB
testcase_22 AC 489 ms
8,704 KB
testcase_23 AC 499 ms
8,576 KB
testcase_24 AC 512 ms
8,704 KB
testcase_25 AC 501 ms
8,832 KB
testcase_26 AC 508 ms
10,240 KB
testcase_27 AC 516 ms
10,240 KB
testcase_28 AC 497 ms
10,240 KB
testcase_29 AC 503 ms
10,240 KB
testcase_30 AC 168 ms
6,144 KB
testcase_31 AC 292 ms
7,552 KB
testcase_32 AC 152 ms
6,144 KB
testcase_33 AC 226 ms
6,784 KB
testcase_34 AC 350 ms
8,576 KB
testcase_35 AC 514 ms
10,496 KB
testcase_36 AC 510 ms
10,496 KB
testcase_37 AC 512 ms
10,496 KB
testcase_38 AC 181 ms
6,272 KB
testcase_39 AC 501 ms
9,856 KB
testcase_40 AC 262 ms
7,040 KB
testcase_41 AC 506 ms
10,240 KB
testcase_42 AC 504 ms
10,496 KB
testcase_43 AC 489 ms
10,496 KB
testcase_44 AC 509 ms
10,496 KB
testcase_45 AC 493 ms
10,496 KB
testcase_46 AC 508 ms
10,496 KB
testcase_47 AC 504 ms
10,496 KB
testcase_48 AC 509 ms
8,704 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

M=10**9+7
m=512
n=read_line.to_i
a=read_line.split.map(&.to_i)
b=(0...m).map{|i|[0i64]*i}
dp=[0i64]*n
dp[0]=1
n.times{|i|
	(1...m).each{|x|dp[i]=(dp[i]+b[x][i% x])%M}
	if a[i]<m
		b[a[i]][i%a[i]]=(b[a[i]][i%a[i]]+dp[i])%M
	else
		j=i+a[i]
		while j<n
			dp[j]=(dp[j]+dp[i])%M
			j+=a[i]
		end
	end
	dp[i+1]=(dp[i+1]+dp[i])%M if i+1<n&&a[i]>1
}
p dp[n-1]
0