結果

問題 No.1331 Moving Penguin
ユーザー yuruhiyayuruhiya
提出日時 2021-01-09 18:41:53
言語 Crystal
(1.11.2)
結果
AC  
実行時間 517 ms / 1,500 ms
コード長 311 bytes
コンパイル時間 17,199 ms
コンパイル使用メモリ 256,012 KB
実行使用メモリ 14,380 KB
最終ジャッジ日時 2023-08-07 11:17:15
合計ジャッジ時間 39,803 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
6,400 KB
testcase_01 AC 4 ms
5,968 KB
testcase_02 AC 4 ms
5,956 KB
testcase_03 AC 4 ms
5,984 KB
testcase_04 AC 507 ms
14,380 KB
testcase_05 AC 502 ms
11,188 KB
testcase_06 AC 503 ms
11,108 KB
testcase_07 AC 504 ms
11,288 KB
testcase_08 AC 491 ms
10,536 KB
testcase_09 AC 494 ms
10,428 KB
testcase_10 AC 493 ms
10,488 KB
testcase_11 AC 494 ms
10,444 KB
testcase_12 AC 498 ms
10,420 KB
testcase_13 AC 498 ms
10,524 KB
testcase_14 AC 502 ms
10,508 KB
testcase_15 AC 503 ms
10,424 KB
testcase_16 AC 500 ms
10,460 KB
testcase_17 AC 503 ms
10,576 KB
testcase_18 AC 506 ms
10,364 KB
testcase_19 AC 504 ms
10,348 KB
testcase_20 AC 487 ms
10,572 KB
testcase_21 AC 485 ms
10,456 KB
testcase_22 AC 485 ms
10,528 KB
testcase_23 AC 500 ms
10,592 KB
testcase_24 AC 500 ms
10,532 KB
testcase_25 AC 501 ms
10,496 KB
testcase_26 AC 516 ms
14,232 KB
testcase_27 AC 517 ms
14,060 KB
testcase_28 AC 513 ms
12,736 KB
testcase_29 AC 503 ms
12,712 KB
testcase_30 AC 173 ms
8,200 KB
testcase_31 AC 290 ms
9,792 KB
testcase_32 AC 153 ms
8,020 KB
testcase_33 AC 223 ms
8,656 KB
testcase_34 AC 343 ms
10,248 KB
testcase_35 AC 504 ms
12,180 KB
testcase_36 AC 505 ms
12,084 KB
testcase_37 AC 507 ms
12,092 KB
testcase_38 AC 180 ms
8,188 KB
testcase_39 AC 494 ms
12,316 KB
testcase_40 AC 257 ms
9,272 KB
testcase_41 AC 506 ms
12,056 KB
testcase_42 AC 506 ms
12,108 KB
testcase_43 AC 506 ms
12,120 KB
testcase_44 AC 506 ms
12,016 KB
testcase_45 AC 503 ms
12,088 KB
testcase_46 AC 505 ms
12,140 KB
testcase_47 AC 507 ms
11,996 KB
testcase_48 AC 486 ms
10,436 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]+=b[x][i% x]%=M}
	if a[i]<m
		b[a[i]][i%a[i]]+=dp[i]%=M
	else
		(i+a[i]).step(to:n-1,by:a[i]){|j|dp[j]+=dp[i]%=M}
	end
	dp[i+1]+=dp[i]%=M if i+1<n&&a[i]>1
}
p dp[-1]%M
0