結果

問題 No.1929 Exponential Sequence
ユーザー rlangevinrlangevin
提出日時 2023-04-12 08:59:40
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,745 bytes
コンパイル時間 457 ms
コンパイル使用メモリ 82,404 KB
実行使用メモリ 180,564 KB
最終ジャッジ日時 2024-04-16 23:30:25
合計ジャッジ時間 4,028 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
52,480 KB
testcase_01 AC 38 ms
52,992 KB
testcase_02 AC 39 ms
52,992 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 38 ms
52,840 KB
testcase_06 AC 37 ms
52,352 KB
testcase_07 AC 38 ms
52,352 KB
testcase_08 WA -
testcase_09 AC 38 ms
52,992 KB
testcase_10 AC 39 ms
52,736 KB
testcase_11 AC 38 ms
52,480 KB
testcase_12 AC 38 ms
52,864 KB
testcase_13 AC 43 ms
52,480 KB
testcase_14 AC 41 ms
52,608 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 39 ms
52,480 KB
testcase_18 AC 39 ms
52,352 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 41 ms
52,224 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from bisect import *

def f(L):
    if L == []:
        return []
    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:])
ans = 0
if not L2:
    L2.append(10 ** 18)
for a in L1:
    ans += bisect_right(L2, S - a)

print(ans)
0