結果
問題 | No.1336 Union on Blackboard |
ユーザー |
|
提出日時 | 2021-01-15 21:40:02 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 62 ms / 2,000 ms |
コード長 | 609 bytes |
コンパイル時間 | 406 ms |
コンパイル使用メモリ | 82,148 KB |
実行使用メモリ | 74,264 KB |
最終ジャッジ日時 | 2024-11-26 13:40:15 |
合計ジャッジ時間 | 3,049 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 31 |
ソースコード
import sysinput = 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)t = int(input())M = 10**9+7def sub(a):n = len(a)dp = [0]*(n+1)dp[0] = 1for i in range(n):ndp = [0]*(n+1)ndp[0] = 1for j in range(1,n+1):ndp[j] = dp[j-1]*a[i] + dp[j]ndp[j] %= Mdp = ndp# print(dp)ans = sum(dp[1:])%Mreturn ansfor _ in range(t):n = int(input())a = list(map(int, input().split()))print(sub(a))