結果

問題 No.1929 Exponential Sequence
ユーザー 👑 H20H20
提出日時 2022-05-06 22:22:52
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 474 ms / 2,000 ms
コード長 660 bytes
コンパイル時間 272 ms
コンパイル使用メモリ 87,112 KB
実行使用メモリ 138,216 KB
最終ジャッジ日時 2023-10-12 04:22:30
合計ジャッジ時間 6,005 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,280 KB
testcase_01 AC 78 ms
71,196 KB
testcase_02 AC 75 ms
71,236 KB
testcase_03 AC 459 ms
138,136 KB
testcase_04 AC 75 ms
71,280 KB
testcase_05 AC 74 ms
71,380 KB
testcase_06 AC 75 ms
71,552 KB
testcase_07 AC 74 ms
71,380 KB
testcase_08 AC 72 ms
71,248 KB
testcase_09 AC 75 ms
71,492 KB
testcase_10 AC 76 ms
71,308 KB
testcase_11 AC 74 ms
71,332 KB
testcase_12 AC 76 ms
71,184 KB
testcase_13 AC 76 ms
71,388 KB
testcase_14 AC 75 ms
71,384 KB
testcase_15 AC 95 ms
76,644 KB
testcase_16 AC 81 ms
75,516 KB
testcase_17 AC 76 ms
71,376 KB
testcase_18 AC 74 ms
71,432 KB
testcase_19 AC 74 ms
71,384 KB
testcase_20 AC 75 ms
71,276 KB
testcase_21 AC 474 ms
137,160 KB
testcase_22 AC 342 ms
116,884 KB
testcase_23 AC 472 ms
136,720 KB
testcase_24 AC 281 ms
110,492 KB
testcase_25 AC 468 ms
131,840 KB
testcase_26 AC 471 ms
138,216 KB
testcase_27 AC 77 ms
71,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import bisect
import sys
sys.setrecursionlimit(10 ** 5)

N,S = map(int, input().split())
A = list(map(int, input().split()))
FA = A[:N//2]
SA = A[N//2:]
FL = []
SL = []

def dfsF(v,i):
    if len(FA)==i:
        FL.append(v)
    else:
        p = 1
        while FA[i]**p+v<=S:
            dfsF(FA[i]**p+v,i+1)
            p+=1

def dfsS(v,i):
    if len(SA)==i:
        SL.append(v)
    else:
        p = 1
        while SA[i]**p+v<=S:
            dfsS(SA[i]**p+v,i+1)
            p+=1

dfsF(0,0)
dfsS(0,0)
FL.sort()
SL.sort()
if N==1:
    print(len(FL)+len(SL)-1)
else:
    ans = 0
    for fl in FL:
        ans+=bisect.bisect_right(SL,S-fl)
    print(ans)

0