結果
問題 | No.1929 Exponential Sequence |
ユーザー | lilictaka |
提出日時 | 2022-05-21 11:52:58 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,510 bytes |
コンパイル時間 | 265 ms |
コンパイル使用メモリ | 82,496 KB |
実行使用メモリ | 85,708 KB |
最終ジャッジ日時 | 2024-09-20 11:26:11 |
合計ジャッジ時間 | 14,212 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 46 ms
54,656 KB |
testcase_01 | AC | 50 ms
60,288 KB |
testcase_02 | AC | 94 ms
76,416 KB |
testcase_03 | AC | 542 ms
85,708 KB |
testcase_04 | AC | 1,080 ms
76,804 KB |
testcase_05 | AC | 48 ms
58,496 KB |
testcase_06 | AC | 43 ms
54,528 KB |
testcase_07 | AC | 140 ms
76,672 KB |
testcase_08 | AC | 43 ms
54,016 KB |
testcase_09 | AC | 100 ms
76,544 KB |
testcase_10 | AC | 47 ms
58,368 KB |
testcase_11 | AC | 145 ms
76,160 KB |
testcase_12 | TLE | - |
testcase_13 | AC | 1,260 ms
76,476 KB |
testcase_14 | TLE | - |
testcase_15 | AC | 1,128 ms
77,392 KB |
testcase_16 | AC | 136 ms
76,800 KB |
testcase_17 | AC | 51 ms
57,856 KB |
testcase_18 | AC | 42 ms
54,932 KB |
testcase_19 | AC | 45 ms
54,016 KB |
testcase_20 | AC | 52 ms
61,696 KB |
testcase_21 | AC | 538 ms
85,376 KB |
testcase_22 | AC | 443 ms
83,052 KB |
testcase_23 | AC | 556 ms
85,460 KB |
testcase_24 | AC | 379 ms
80,268 KB |
testcase_25 | AC | 541 ms
85,548 KB |
testcase_26 | AC | 539 ms
85,396 KB |
testcase_27 | AC | 148 ms
76,672 KB |
ソースコード
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: break 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: break 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)