結果

問題 No.10 +か×か
ユーザー titiatitia
提出日時 2021-11-02 01:23:54
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 478 bytes
コンパイル時間 106 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 10,880 KB
最終ジャッジ日時 2024-04-19 03:47:15
合計ジャッジ時間 6,734 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
10,752 KB
testcase_01 AC 32 ms
10,752 KB
testcase_02 AC 31 ms
10,752 KB
testcase_03 TLE -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

N=int(input())
T=int(input())
A=list(map(int,input().split()))

S=[0,A[0]]
for a in A[1:]:
    S.append(min(S[-1]+a,S[-1]*a))

def calc(i,T):
    #print(i,T)
    if i==0:
        if T==A[0]:
            return ""
        else:
            return -1
        
    if calc(i-1,T-A[i])!=-1:
        return calc(i-1,T-A[i])+"+"

    if T%A[i]==0 and T//A[i]>=S[i]:
        if calc(i-1,T//A[i])!=-1:
            return calc(i-1,T//A[i])+"*"
        
    return -1

print(calc(N-1,T))
0