結果

問題 No.1929 Exponential Sequence
ユーザー rlangevinrlangevin
提出日時 2023-04-12 12:25:55
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 397 ms / 2,000 ms
コード長 1,721 bytes
コンパイル時間 150 ms
コンパイル使用メモリ 82,764 KB
実行使用メモリ 184,960 KB
最終ジャッジ日時 2024-04-17 01:48:36
合計ジャッジ時間 3,991 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
52,224 KB
testcase_01 AC 37 ms
52,224 KB
testcase_02 AC 36 ms
52,608 KB
testcase_03 AC 397 ms
184,960 KB
testcase_04 AC 37 ms
52,096 KB
testcase_05 AC 36 ms
52,736 KB
testcase_06 AC 37 ms
52,464 KB
testcase_07 AC 35 ms
52,608 KB
testcase_08 AC 37 ms
52,224 KB
testcase_09 AC 36 ms
52,096 KB
testcase_10 AC 35 ms
52,736 KB
testcase_11 AC 35 ms
52,736 KB
testcase_12 AC 35 ms
52,480 KB
testcase_13 AC 34 ms
52,352 KB
testcase_14 AC 35 ms
52,480 KB
testcase_15 AC 51 ms
64,512 KB
testcase_16 AC 41 ms
58,112 KB
testcase_17 AC 35 ms
52,480 KB
testcase_18 AC 37 ms
52,352 KB
testcase_19 AC 39 ms
51,968 KB
testcase_20 AC 37 ms
52,224 KB
testcase_21 AC 340 ms
184,856 KB
testcase_22 AC 221 ms
143,776 KB
testcase_23 AC 311 ms
184,320 KB
testcase_24 AC 185 ms
121,984 KB
testcase_25 AC 313 ms
173,812 KB
testcase_26 AC 305 ms
184,960 KB
testcase_27 AC 33 ms
52,224 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from bisect import *

def f(L):
    if L == []:
        return [0]
    n = len(L)
    temp = []
    if n == 1:
        for a in range(1, 31):
            v1 = L[0] ** a
            if v1 > S:
                break
            temp.append(v1)
    elif n == 2:
        for a in range(1, 31):
            v1 = L[0] ** a
            if v1 > S:
                break
            for b in range(1, 31):
                v2 = v1 + L[1] ** b
                if v2 > S:
                    break
                temp.append(v2)
    elif n == 3:
        for a in range(1, 31):
            v1 = L[0] ** a
            if v1 > S:
                break
            for b in range(1, 31):
                v2 = v1 + L[1] ** b
                if v2 > S:
                    break
                for c in range(1, 31):
                    v3 = v2 + L[2] ** c
                    if v3 > S:
                        break
                    temp.append(v3)
    else:
        for a in range(1, 31):
            v1 = L[0] ** a
            if v1 > S:
                break
            for b in range(1, 31):
                v2 = v1 + L[1] ** b
                if v2 > S:
                    break
                for c in range(1, 31):
                    v3 = v2 + L[2] ** c
                    if v3 > S:
                        break
                    for d in range(1, 31):
                        v4 = v3 + L[3] ** d
                        if v4 > S:
                            break
                        temp.append(v4)
    return temp

N, S = map(int, input().split())
A = list(map(int, input().split()))

N1 = (N + 1)//2
L1, L2 = f(A[:N1]), f(A[N1:])
L2.sort()
ans = 0
for a in L1:
    ans += bisect_right(L2, S - a)

print(ans)
0