結果

問題 No.1025 Modular Equation
ユーザー chocoruskchocorusk
提出日時 2020-04-08 13:52:18
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 798 bytes
コンパイル時間 146 ms
コンパイル使用メモリ 10,892 KB
実行使用メモリ 17,796 KB
最終ジャッジ日時 2023-09-25 14:02:34
合計ジャッジ時間 8,479 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
8,036 KB
testcase_01 AC 16 ms
7,960 KB
testcase_02 AC 39 ms
8,908 KB
testcase_03 AC 155 ms
8,212 KB
testcase_04 AC 120 ms
8,048 KB
testcase_05 AC 108 ms
8,044 KB
testcase_06 AC 74 ms
7,988 KB
testcase_07 AC 108 ms
8,028 KB
testcase_08 AC 123 ms
7,964 KB
testcase_09 TLE -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import math
p, n, k, b=map(int, input().split())
a=list(map(int, input().split()))
r=1
for i in range(1, p):
    dame=False
    pp=1
    for j in range(p-2):
        pp*=i
        pp%=p
        if pp==1:
            dame=True
            break
    if not dame:
        r=i
        break
q=[1]*(p-1)
k=math.gcd(k, p-1)
for i in range(1, p-1):
    q[i]=q[i-1]*r%p
MOD=10**9+7
dp=[0]*p
tmp=[0]*p
dp[0]=1
for ai in a:
    for i in range(p):
        tmp[i]=dp[i]
    for j in range(0, p-1, k):
        tmp[0]+=dp[(-ai*q[j])%p]*k
        tmp[0]%=MOD
    for i in range(k):
        for j in range(0, p-1, k):
            tmp[q[i]]+=dp[(q[i]-ai*q[j])%p]*k
            tmp[q[i]]%=MOD
        for j in range(i, p-1, k):
            tmp[q[j]]=tmp[q[i]]
    for i in range(p):
        dp[i]=tmp[i]
print(dp[b])
0