結果
問題 | No.1929 Exponential Sequence |
ユーザー | lilictaka |
提出日時 | 2022-05-21 11:48:11 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,423 bytes |
コンパイル時間 | 221 ms |
コンパイル使用メモリ | 81,792 KB |
実行使用メモリ | 84,968 KB |
最終ジャッジ日時 | 2023-10-20 15:52:00 |
合計ジャッジ時間 | 5,130 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 46 ms
62,280 KB |
testcase_01 | AC | 62 ms
76,168 KB |
testcase_02 | AC | 135 ms
76,244 KB |
testcase_03 | AC | 544 ms
84,968 KB |
testcase_04 | TLE | - |
testcase_05 | -- | - |
testcase_06 | -- | - |
testcase_07 | -- | - |
testcase_08 | -- | - |
testcase_09 | -- | - |
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 | -- | - |
ソースコード
from bisect import bisect_left def acum(List):#累積和 rev = [0 for _ in range(len(List))] for i in range(len(List)): if i == 0: rev[i] = List[i] else: rev[i] = rev[i-1] + List[i] return rev from collections import defaultdict from itertools import product n,S = map(int,input().split()) A = list(map(int,input().split())) cntP = defaultdict(int) cntQ = defaultdict(int) if n >= 2: front = [] back = [] for a in A[:n//2]: front .append(a) for a in A[n//2:]: back.append(a) for Ks in product([i for i in range(1,33)],repeat = len(front)): P = 0 for l in range(len(front)): P += pow(front[l],Ks[l]) if P <= S: cntP[P] += 1 qlist = set() for Ks in product([i for i in range(1,33)],repeat=len(back)): Q = 0 for l in range(len(back)): Q += pow(back[l],Ks[l]) if Q <= S: cntQ[Q] += 1 qlist.add(Q) qlist = sorted(list(qlist)) value = [] for q in qlist: value.append(cntQ[q]) cum = acum(value) ans = 0 for p in cntP.keys(): index = bisect_left(qlist,S-p+1) -1 if index == -1: continue ans += cntP[p] * cum[index] print(ans) else: for k in range(1,33): if pow(A[0],k) <= S: pass else: break print(k-1)