結果

問題 No.1929 Exponential Sequence
ユーザー tassei903tassei903
提出日時 2022-05-06 22:37:09
言語 PyPy3
(7.3.15)
結果
MLE  
実行時間 -
コード長 1,211 bytes
コンパイル時間 801 ms
コンパイル使用メモリ 87,300 KB
実行使用メモリ 582,572 KB
最終ジャッジ日時 2023-09-20 03:40:41
合計ジャッジ時間 6,751 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 119 ms
72,460 KB
testcase_01 AC 117 ms
72,540 KB
testcase_02 AC 122 ms
76,708 KB
testcase_03 AC 140 ms
78,108 KB
testcase_04 AC 139 ms
77,880 KB
testcase_05 AC 118 ms
72,388 KB
testcase_06 AC 119 ms
72,524 KB
testcase_07 AC 131 ms
77,588 KB
testcase_08 AC 118 ms
72,384 KB
testcase_09 AC 117 ms
72,384 KB
testcase_10 AC 119 ms
72,384 KB
testcase_11 AC 119 ms
72,384 KB
testcase_12 AC 119 ms
72,476 KB
testcase_13 AC 116 ms
72,364 KB
testcase_14 AC 116 ms
72,368 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):
    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
for i in d:
    ans += d[i] * saiki((s-i)//2,c)
print(ans)
0