結果

問題 No.1331 Moving Penguin
ユーザー shotoyooshotoyoo
提出日時 2021-01-08 22:03:45
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 750 ms / 1,500 ms
コード長 791 bytes
コンパイル時間 443 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 93,824 KB
最終ジャッジ日時 2024-04-25 04:42:31
合計ジャッジ時間 19,145 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 123 ms
74,112 KB
testcase_01 AC 41 ms
52,224 KB
testcase_02 AC 41 ms
51,840 KB
testcase_03 AC 41 ms
52,224 KB
testcase_04 AC 662 ms
93,824 KB
testcase_05 AC 276 ms
89,856 KB
testcase_06 AC 278 ms
89,856 KB
testcase_07 AC 279 ms
89,856 KB
testcase_08 AC 98 ms
89,600 KB
testcase_09 AC 102 ms
89,728 KB
testcase_10 AC 102 ms
89,472 KB
testcase_11 AC 102 ms
89,728 KB
testcase_12 AC 101 ms
89,728 KB
testcase_13 AC 103 ms
89,600 KB
testcase_14 AC 112 ms
89,984 KB
testcase_15 AC 114 ms
89,472 KB
testcase_16 AC 114 ms
89,600 KB
testcase_17 AC 107 ms
89,856 KB
testcase_18 AC 106 ms
89,856 KB
testcase_19 AC 108 ms
89,728 KB
testcase_20 AC 103 ms
89,728 KB
testcase_21 AC 103 ms
89,728 KB
testcase_22 AC 102 ms
89,856 KB
testcase_23 AC 105 ms
89,600 KB
testcase_24 AC 106 ms
89,600 KB
testcase_25 AC 103 ms
89,600 KB
testcase_26 AC 675 ms
91,648 KB
testcase_27 AC 684 ms
91,392 KB
testcase_28 AC 675 ms
91,520 KB
testcase_29 AC 645 ms
91,520 KB
testcase_30 AC 281 ms
80,512 KB
testcase_31 AC 418 ms
84,224 KB
testcase_32 AC 258 ms
80,128 KB
testcase_33 AC 345 ms
81,920 KB
testcase_34 AC 483 ms
86,272 KB
testcase_35 AC 746 ms
91,136 KB
testcase_36 AC 727 ms
91,520 KB
testcase_37 AC 725 ms
91,136 KB
testcase_38 AC 295 ms
80,384 KB
testcase_39 AC 655 ms
91,392 KB
testcase_40 AC 380 ms
82,816 KB
testcase_41 AC 687 ms
91,264 KB
testcase_42 AC 747 ms
90,880 KB
testcase_43 AC 738 ms
91,008 KB
testcase_44 AC 750 ms
90,624 KB
testcase_45 AC 740 ms
91,136 KB
testcase_46 AC 742 ms
90,880 KB
testcase_47 AC 750 ms
90,752 KB
testcase_48 AC 94 ms
89,600 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = lambda : sys.stdin.readline().rstrip()

sys.setrecursionlimit(2*10**5+10)
write = lambda x: sys.stdout.write(x+"\n")
_print = lambda *x: print(*x, file=sys.stderr)

n = int(input())
a = list(map(int, input().split()))
B = min(300, max(a)+1)
dp = [0]*(n)
dp[0] = 1
M = 10**9+7
vals = [[0]*B for _ in range(B)]
def sub(i):
    res = 0
    for v in range(1,B):
        res += vals[v][i%v]
        res %= M
    return res
#     return sum(vals[v][i%v] for v in range(1,B))%M
for i,v in enumerate(a):
    dp[i] += sub(i)
    if i==n-1:
        break
    if v>=2:
        dp[i+1] += dp[i]
    if v>=B:
        for j in range(i+v,n,v):
            dp[j] += dp[i]
            dp[j] %= M
    else:
        vals[v][i%v] += dp[i]
        vals[v][i%v] %= M
ans = dp[-1]%M
print(ans%M)
0