結果

問題 No.1929 Exponential Sequence
ユーザー tassei903tassei903
提出日時 2022-05-06 23:03:40
言語 PyPy3
(7.3.15)
結果
MLE  
実行時間 -
コード長 1,332 bytes
コンパイル時間 1,648 ms
コンパイル使用メモリ 86,688 KB
実行使用メモリ 630,156 KB
最終ジャッジ日時 2023-09-20 05:20:01
合計ジャッジ時間 7,370 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 111 ms
72,248 KB
testcase_01 AC 111 ms
72,180 KB
testcase_02 AC 111 ms
72,056 KB
testcase_03 AC 134 ms
77,428 KB
testcase_04 AC 135 ms
77,432 KB
testcase_05 AC 112 ms
72,296 KB
testcase_06 AC 113 ms
72,216 KB
testcase_07 AC 123 ms
77,140 KB
testcase_08 AC 111 ms
72,112 KB
testcase_09 AC 111 ms
72,324 KB
testcase_10 AC 112 ms
72,216 KB
testcase_11 AC 112 ms
72,264 KB
testcase_12 AC 111 ms
72,364 KB
testcase_13 AC 111 ms
72,308 KB
testcase_14 AC 112 ms
72,108 KB
testcase_15 MLE -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = lambda :sys.stdin.readline()[:-1]
ni = lambda :int(input())
na = lambda :list(map(int,input().split()))
yes = lambda :print("yes");Yes = lambda :print("Yes");YES = lambda : print("YES")
no = lambda :print("no");No = lambda :print("No");NO = lambda : print("NO")
#######################################################################


n,s = na()
a = na()
b = []
c = 0
for i in range(n):
    if a[i]!=2:
        b.append(a[i])
    else:
        c += 1
a = b
n = len(b)
kai = [1]
for i in range(8):
    kai.append(kai[-1]*(i+1))
def binom(r,x):
    return kai[r]//kai[x]//kai[r-x]
import functools
@functools.lru_cache(maxsize=None)
def saiki(s, c):
    if c == 1:
        r = 0
        while s > 0:
            r += 1
            s //= 2
        return r
    r = 0
    if c == 0 and s >= 0:
        return 1
    if s < c:
        return 0
    if s == c:
        return 1
    for i in range(c+1):
        r += binom(c,i)*saiki((s-i)//2, c-i)
    return r
    

from collections import defaultdict

d = defaultdict(int)
d[0] = 1
for i in range(n):
    od = defaultdict(int)
    d,od = od,d
    for j in od:
        x = a[i]
        while j + x <= s:
            d[j + x]+=od[j]
            x *= a[i]
    #print(d)
    #print(len(d))
ans = 0
#print(len(d))
for i in d:
    ans += d[i] * saiki((s-i)//2,c)
print(ans)
0