結果

問題 No.1929 Exponential Sequence
ユーザー roarisroaris
提出日時 2022-06-10 02:30:32
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 491 bytes
コンパイル時間 82 ms
コンパイル使用メモリ 11,920 KB
実行使用メモリ 232,472 KB
最終ジャッジ日時 2023-10-21 04:34:52
合計ジャッジ時間 18,581 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 26 ms
10,228 KB
testcase_01 AC 29 ms
10,308 KB
testcase_02 AC 49 ms
13,080 KB
testcase_03 AC 1,329 ms
79,652 KB
testcase_04 AC 735 ms
72,072 KB
testcase_05 AC 27 ms
10,248 KB
testcase_06 AC 25 ms
10,204 KB
testcase_07 AC 71 ms
13,960 KB
testcase_08 AC 26 ms
10,204 KB
testcase_09 AC 51 ms
13,912 KB
testcase_10 AC 26 ms
10,304 KB
testcase_11 AC 87 ms
17,336 KB
testcase_12 TLE -
testcase_13 AC 959 ms
127,952 KB
testcase_14 TLE -
testcase_15 AC 1,388 ms
107,688 KB
testcase_16 AC 69 ms
13,444 KB
testcase_17 AC 27 ms
10,244 KB
testcase_18 AC 25 ms
10,204 KB
testcase_19 AC 27 ms
10,204 KB
testcase_20 AC 27 ms
10,292 KB
testcase_21 AC 1,341 ms
79,652 KB
testcase_22 AC 1,345 ms
79,652 KB
testcase_23 AC 1,332 ms
79,652 KB
testcase_24 AC 1,320 ms
79,652 KB
testcase_25 AC 1,326 ms
79,652 KB
testcase_26 AC 1,346 ms
79,652 KB
testcase_27 AC 91 ms
17,256 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from bisect import *

def dfs1(s, dep):
    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 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