結果
問題 | No.1929 Exponential Sequence |
ユーザー | lilictaka |
提出日時 | 2022-05-21 12:08:25 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 1,846 ms / 2,000 ms |
コード長 | 1,827 bytes |
コンパイル時間 | 396 ms |
コンパイル使用メモリ | 82,304 KB |
実行使用メモリ | 135,868 KB |
最終ジャッジ日時 | 2024-09-20 11:27:03 |
合計ジャッジ時間 | 12,033 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 40 ms
53,504 KB |
testcase_01 | AC | 45 ms
57,472 KB |
testcase_02 | AC | 83 ms
76,288 KB |
testcase_03 | AC | 543 ms
135,660 KB |
testcase_04 | AC | 825 ms
76,288 KB |
testcase_05 | AC | 42 ms
56,064 KB |
testcase_06 | AC | 39 ms
53,248 KB |
testcase_07 | AC | 120 ms
76,160 KB |
testcase_08 | AC | 37 ms
52,480 KB |
testcase_09 | AC | 88 ms
75,776 KB |
testcase_10 | AC | 41 ms
56,320 KB |
testcase_11 | AC | 125 ms
75,648 KB |
testcase_12 | AC | 1,773 ms
76,288 KB |
testcase_13 | AC | 932 ms
76,288 KB |
testcase_14 | AC | 1,846 ms
76,160 KB |
testcase_15 | AC | 868 ms
76,672 KB |
testcase_16 | AC | 121 ms
76,372 KB |
testcase_17 | AC | 41 ms
55,680 KB |
testcase_18 | AC | 39 ms
53,120 KB |
testcase_19 | AC | 38 ms
52,608 KB |
testcase_20 | AC | 45 ms
58,880 KB |
testcase_21 | AC | 555 ms
135,436 KB |
testcase_22 | AC | 402 ms
108,612 KB |
testcase_23 | AC | 534 ms
135,384 KB |
testcase_24 | AC | 325 ms
95,840 KB |
testcase_25 | AC | 529 ms
123,816 KB |
testcase_26 | AC | 554 ms
135,868 KB |
testcase_27 | AC | 126 ms
75,648 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 itertools import product n,S = map(int,input().split()) A = list(map(int,input().split())) if n >= 2: front = [] back = [] for a in A[:n//2]: front .append(a) for a in A[n//2:]: back.append(a) Plist = [] for Ks in product([i for i in range(1,31)],repeat = len(front)): P = 0 for l in range(len(front)): P += pow(front[l],Ks[l]) if P > S: break if P <= S: Plist.append(P) Qlist = [] for Ks in product([i for i in range(1,31)],repeat=len(back)): Q = 0 for l in range(len(back)): Q += pow(back[l],Ks[l]) if Q > S: break if Q <= S: Qlist.append(Q) Plist.sort() Qlist.sort() cntP = [0] * len(set(Plist)) cntQ = [0] * len(set(Qlist)) index = 0 qlist = sorted(list(set(Qlist))) plist = sorted(list(set(Plist))) for p in Plist: if plist[index] == p: cntP[index] += 1 else: index += 1 cntP[index] += 1 index = 0 for q in Qlist: if qlist[index] == q: cntQ[index] += 1 else: index += 1 cntQ[index] += 1 cum = acum(cntQ) ans = 0 for i,p in enumerate(plist): index = bisect_left(qlist,S-p+1) -1 if index == -1: continue ans += cntP[i] * cum[index] print(ans) else: for k in range(1,33): if pow(A[0],k) <= S: pass else: break print(k-1)