結果
問題 | No.2394 部分和乗総和 |
ユーザー |
![]() |
提出日時 | 2024-05-09 16:45:34 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 368 ms / 2,000 ms |
コード長 | 948 bytes |
コンパイル時間 | 445 ms |
コンパイル使用メモリ | 82,176 KB |
実行使用メモリ | 114,048 KB |
最終ジャッジ日時 | 2024-05-09 16:45:42 |
合計ジャッジ時間 | 6,213 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 127 ms
88,576 KB |
testcase_01 | AC | 125 ms
88,380 KB |
testcase_02 | AC | 125 ms
88,704 KB |
testcase_03 | AC | 126 ms
88,960 KB |
testcase_04 | AC | 129 ms
88,960 KB |
testcase_05 | AC | 121 ms
88,568 KB |
testcase_06 | AC | 122 ms
88,764 KB |
testcase_07 | AC | 147 ms
88,704 KB |
testcase_08 | AC | 125 ms
88,728 KB |
testcase_09 | AC | 126 ms
88,540 KB |
testcase_10 | AC | 126 ms
88,812 KB |
testcase_11 | AC | 125 ms
88,496 KB |
testcase_12 | AC | 122 ms
88,812 KB |
testcase_13 | AC | 156 ms
90,624 KB |
testcase_14 | AC | 212 ms
97,024 KB |
testcase_15 | AC | 245 ms
97,920 KB |
testcase_16 | AC | 252 ms
102,016 KB |
testcase_17 | AC | 339 ms
114,048 KB |
testcase_18 | AC | 348 ms
113,664 KB |
testcase_19 | AC | 368 ms
113,920 KB |
testcase_20 | AC | 315 ms
110,080 KB |
ソースコード
from heapq import heappush, heappop, heapify import sys from collections import defaultdict, deque,Counter from math import ceil, floor, sqrt, factorial,gcd from itertools import permutations, combinations,product,accumulate from bisect import bisect_left, bisect_right from copy import deepcopy from functools import lru_cache from fractions import Fraction sys.setrecursionlimit(10**7) # input = sys.stdin.readline vector1 = [[0, -1], [1, 0], [0, 1], [-1, 0]] vector2 = [[0, 1], [1, 0], [-1, 0], [0, -1], [1,-1], [-1, 1], [1, 1], [-1, -1]] def main(): N,M,mod = map(int,input().split()) A = list(map(int,input().split())) dp = [[0,0] for i in range(N)] #A[i]が[ない、ある] dp[0] = [1,pow(M,A[0],mod)] for i in range(1,N): dp[i][0] = sum(dp[i-1]) * pow(M,A[i],mod) % mod dp[i][1] = sum(dp[i-1]) print(sum(dp[-1])%mod) if __name__ == "__main__": main()