結果

問題 No.1929 Exponential Sequence
ユーザー 👑 H20H20
提出日時 2022-05-06 22:20:15
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 650 bytes
コンパイル時間 289 ms
コンパイル使用メモリ 87,136 KB
実行使用メモリ 137,940 KB
最終ジャッジ日時 2023-09-20 03:16:52
合計ジャッジ時間 6,321 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
71,556 KB
testcase_01 AC 75 ms
71,152 KB
testcase_02 AC 76 ms
71,268 KB
testcase_03 AC 482 ms
137,780 KB
testcase_04 AC 77 ms
71,336 KB
testcase_05 AC 77 ms
71,368 KB
testcase_06 AC 75 ms
71,256 KB
testcase_07 AC 79 ms
71,412 KB
testcase_08 WA -
testcase_09 AC 77 ms
71,416 KB
testcase_10 AC 78 ms
71,420 KB
testcase_11 AC 75 ms
71,408 KB
testcase_12 AC 75 ms
71,272 KB
testcase_13 AC 75 ms
71,252 KB
testcase_14 AC 75 ms
71,408 KB
testcase_15 AC 96 ms
76,348 KB
testcase_16 AC 83 ms
75,312 KB
testcase_17 AC 77 ms
71,220 KB
testcase_18 AC 79 ms
71,328 KB
testcase_19 WA -
testcase_20 AC 77 ms
71,436 KB
testcase_21 AC 483 ms
137,280 KB
testcase_22 AC 350 ms
117,096 KB
testcase_23 AC 479 ms
137,120 KB
testcase_24 AC 287 ms
110,412 KB
testcase_25 AC 472 ms
131,692 KB
testcase_26 AC 485 ms
137,940 KB
testcase_27 AC 77 ms
71,404 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(FA))
else:
    ans = 0
    for fl in FL:
        ans+=bisect.bisect_right(SL,S-fl)
    print(ans)

0