結果
問題 | No.2709 1975 Powers |
ユーザー | FromBooska |
提出日時 | 2024-03-31 18:23:53 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,043 bytes |
コンパイル時間 | 212 ms |
コンパイル使用メモリ | 81,700 KB |
実行使用メモリ | 205,972 KB |
最終ジャッジ日時 | 2024-03-31 18:24:22 |
合計ジャッジ時間 | 27,465 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 35 ms
53,460 KB |
testcase_01 | AC | 37 ms
53,460 KB |
testcase_02 | AC | 158 ms
105,436 KB |
testcase_03 | AC | 1,297 ms
134,008 KB |
testcase_04 | AC | 1,970 ms
183,420 KB |
testcase_05 | AC | 1,491 ms
159,028 KB |
testcase_06 | AC | 611 ms
93,920 KB |
testcase_07 | AC | 61 ms
71,392 KB |
testcase_08 | AC | 701 ms
154,872 KB |
testcase_09 | AC | 1,515 ms
168,772 KB |
testcase_10 | AC | 63 ms
72,280 KB |
testcase_11 | AC | 158 ms
83,860 KB |
testcase_12 | AC | 334 ms
134,996 KB |
testcase_13 | AC | 1,578 ms
192,500 KB |
testcase_14 | AC | 413 ms
102,684 KB |
testcase_15 | AC | 515 ms
150,844 KB |
testcase_16 | AC | 1,235 ms
117,916 KB |
testcase_17 | AC | 89 ms
79,064 KB |
testcase_18 | AC | 382 ms
138,100 KB |
testcase_19 | AC | 1,950 ms
172,668 KB |
testcase_20 | AC | 146 ms
104,216 KB |
testcase_21 | AC | 680 ms
152,076 KB |
testcase_22 | TLE | - |
testcase_23 | TLE | - |
testcase_24 | TLE | - |
testcase_25 | TLE | - |
testcase_26 | TLE | - |
ソースコード
# 200の4乗は不可能だが、200の3乗ならできる、最後だけ事前カウントしておくのはどうだろう # これでダメなら先頭2項のmod、後半2項のmodで可能かも N, P, Q = map(int, input().split()) A = list(map(int, input().split())) A.sort() #print(A) last_count = [[0]*P for i in range(N)] for i in range(N-1, -1, -1): if i == N-1: calc = pow(5, A[i], P) last_count[i][calc] += 1 else: for j in range(P): last_count[i][j] = last_count[i+1][j] calc = pow(5, A[i], P) last_count[i][calc] += 1 #print('i', i, 'calc', calc) #for l in last_count: # print(l) # Ai!=Ajなのでダブりは考えなくていい ans = 0 for a in range(N-3): for b in range(a+1, N-2): for c in range(b+1, N-1): calc = pow(10, A[a], P)+pow(9, A[b], P)+pow(7, A[c], P) needed = (Q-calc)%P #print(a, b, c, 'needed', needed) count = last_count[c+1][needed] ans += count print(ans)