結果

問題 No.1929 Exponential Sequence
ユーザー lilictaka
提出日時 2022-05-21 11:27:05
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 1,049 bytes
コンパイル時間 178 ms
コンパイル使用メモリ 81,916 KB
実行使用メモリ 88,448 KB
最終ジャッジ日時 2024-09-20 11:24:09
合計ジャッジ時間 4,220 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3 TLE * 1
other -- * 24
権限があれば一括ダウンロードができます

ソースコード

diff #

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
    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
    ans = 0
    for p in cntP.keys():
        for q in cntQ.keys():
            if p + q <= S:
                ans += cntP[p] * cntQ[q]
    print(ans)
else:
    for k in range(1,33):
        if pow(A[0],k) <= S:
            pass
        else:
            break
    print(k-1)


    






    
    

    

 

    


        
        




0