結果

問題 No.1929 Exponential Sequence
ユーザー 👑 H20H20
提出日時 2022-05-06 22:20:59
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 658 bytes
コンパイル時間 424 ms
コンパイル使用メモリ 86,908 KB
実行使用メモリ 138,224 KB
最終ジャッジ日時 2023-09-20 03:18:39
合計ジャッジ時間 6,104 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,372 KB
testcase_01 AC 72 ms
71,476 KB
testcase_02 AC 72 ms
71,368 KB
testcase_03 AC 457 ms
138,224 KB
testcase_04 AC 73 ms
71,368 KB
testcase_05 AC 72 ms
71,272 KB
testcase_06 AC 72 ms
71,280 KB
testcase_07 AC 72 ms
71,104 KB
testcase_08 WA -
testcase_09 AC 73 ms
71,424 KB
testcase_10 AC 78 ms
71,360 KB
testcase_11 AC 74 ms
71,556 KB
testcase_12 AC 74 ms
71,284 KB
testcase_13 AC 73 ms
71,392 KB
testcase_14 AC 72 ms
71,444 KB
testcase_15 AC 91 ms
76,716 KB
testcase_16 AC 78 ms
75,472 KB
testcase_17 AC 72 ms
71,408 KB
testcase_18 AC 72 ms
71,104 KB
testcase_19 WA -
testcase_20 AC 72 ms
71,224 KB
testcase_21 AC 475 ms
137,412 KB
testcase_22 AC 343 ms
117,080 KB
testcase_23 AC 481 ms
137,300 KB
testcase_24 AC 278 ms
110,552 KB
testcase_25 AC 458 ms
131,624 KB
testcase_26 AC 467 ms
137,904 KB
testcase_27 AC 73 ms
71,320 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))
else:
    ans = 0
    for fl in FL:
        ans+=bisect.bisect_right(SL,S-fl)
    print(ans)

0