結果

問題 No.1929 Exponential Sequence
ユーザー roarisroaris
提出日時 2022-06-10 02:31:48
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 480 ms / 2,000 ms
コード長 555 bytes
コンパイル時間 223 ms
コンパイル使用メモリ 81,784 KB
実行使用メモリ 130,840 KB
最終ジャッジ日時 2023-10-21 04:34:56
合計ジャッジ時間 4,654 ms
ジャッジサーバーID
(参考情報)
judge14 / judge10
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
53,404 KB
testcase_01 AC 39 ms
53,404 KB
testcase_02 AC 40 ms
53,404 KB
testcase_03 AC 480 ms
125,884 KB
testcase_04 AC 47 ms
63,640 KB
testcase_05 AC 41 ms
53,404 KB
testcase_06 AC 40 ms
53,404 KB
testcase_07 AC 41 ms
55,452 KB
testcase_08 AC 39 ms
53,404 KB
testcase_09 AC 39 ms
53,404 KB
testcase_10 AC 39 ms
53,404 KB
testcase_11 AC 40 ms
53,404 KB
testcase_12 AC 40 ms
53,404 KB
testcase_13 AC 39 ms
53,404 KB
testcase_14 AC 40 ms
53,404 KB
testcase_15 AC 92 ms
75,788 KB
testcase_16 AC 60 ms
72,800 KB
testcase_17 AC 40 ms
53,404 KB
testcase_18 AC 40 ms
53,404 KB
testcase_19 AC 38 ms
53,404 KB
testcase_20 AC 40 ms
53,404 KB
testcase_21 AC 392 ms
130,840 KB
testcase_22 AC 286 ms
112,688 KB
testcase_23 AC 389 ms
130,680 KB
testcase_24 AC 231 ms
104,284 KB
testcase_25 AC 392 ms
125,232 KB
testcase_26 AC 379 ms
125,932 KB
testcase_27 AC 40 ms
53,404 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from bisect import *

def dfs1(s, dep):
    if s>S:
        return
    
    if dep==n//2:
        l1.append(s)
        return
    
    for k in range(1, 31):
        dfs1(s+pow(a[dep], k), dep+1)

def dfs2(s, dep):
    if s>S:
        return
    
    if dep==n:
        l2.append(s)
        return
    
    for k in range(1, 31):
        dfs2(s+pow(a[dep], k), dep+1)

n, S = map(int, input().split())
a = list(map(int, input().split()))
l1, l2 = [], []
dfs1(0, 0)
dfs2(0, n//2)
l2.sort()
ans = 0

for v in l1:
    ans += bisect_right(l2, S-v)

print(ans)
0