結果

問題 No.2709 1975 Powers
ユーザー 👑 tipstar0125tipstar0125
提出日時 2024-03-31 15:49:50
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 870 ms / 2,000 ms
コード長 510 bytes
コンパイル時間 203 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 75,524 KB
最終ジャッジ日時 2024-03-31 15:50:01
合計ジャッジ時間 10,807 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,460 KB
testcase_01 AC 37 ms
53,460 KB
testcase_02 AC 55 ms
64,336 KB
testcase_03 AC 457 ms
75,472 KB
testcase_04 AC 743 ms
75,472 KB
testcase_05 AC 506 ms
75,516 KB
testcase_06 AC 198 ms
75,504 KB
testcase_07 AC 47 ms
59,984 KB
testcase_08 AC 194 ms
75,520 KB
testcase_09 AC 504 ms
75,504 KB
testcase_10 AC 46 ms
62,136 KB
testcase_11 AC 66 ms
66,424 KB
testcase_12 AC 89 ms
70,520 KB
testcase_13 AC 554 ms
75,512 KB
testcase_14 AC 115 ms
72,528 KB
testcase_15 AC 137 ms
75,524 KB
testcase_16 AC 412 ms
75,504 KB
testcase_17 AC 51 ms
64,332 KB
testcase_18 AC 100 ms
70,512 KB
testcase_19 AC 715 ms
75,512 KB
testcase_20 AC 60 ms
66,424 KB
testcase_21 AC 184 ms
75,512 KB
testcase_22 AC 850 ms
75,472 KB
testcase_23 AC 870 ms
75,504 KB
testcase_24 AC 838 ms
75,516 KB
testcase_25 AC 855 ms
75,472 KB
testcase_26 AC 859 ms
75,472 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from itertools import combinations
N,P,Q=list(map(int,input().split()))
A=list(map(int,input().split()))
A.sort()

M=[[0 for _ in range(4)] for _ in range(N)]
for (i,a) in enumerate(A):
    M[i][0]=pow(10,a,P)
    M[i][1]=pow(9,a,P)
    M[i][2]=pow(7,a,P)
    M[i][3]=pow(5,a,P)

ans=0
for i in range(N):
    for j in range(i+1,N):
        for k in range(j+1,N):
            for l in range(k+1,N):
                x=M[i][0]+M[j][1]+M[k][2]+M[l][3]
                x%=P
                if x==Q:ans+=1
print(ans)
0