結果
問題 | No.10 +か×か |
ユーザー |
|
提出日時 | 2021-02-05 08:15:15 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
AC
|
実行時間 | 712 ms / 5,000 ms |
コード長 | 488 bytes |
コンパイル時間 | 154 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 75,344 KB |
最終ジャッジ日時 | 2024-12-14 15:47:10 |
合計ジャッジ時間 | 2,502 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 30 ms
10,752 KB |
testcase_01 | AC | 26 ms
10,752 KB |
testcase_02 | AC | 29 ms
10,880 KB |
testcase_03 | AC | 393 ms
46,724 KB |
testcase_04 | AC | 37 ms
11,904 KB |
testcase_05 | AC | 30 ms
10,880 KB |
testcase_06 | AC | 712 ms
75,344 KB |
testcase_07 | AC | 339 ms
42,340 KB |
testcase_08 | AC | 52 ms
14,976 KB |
testcase_09 | AC | 67 ms
16,176 KB |
testcase_10 | AC | 26 ms
10,752 KB |
testcase_11 | AC | 27 ms
10,752 KB |
ソースコード
from collections import deque N = int(input()) T = int(input()) A = tuple(map(int, input().split())) stk = deque() visited = set() def rec(i, x): if (i, x) in visited: return if i == N and x == T: res = ''.join(map(str, stk)) print(res) exit() elif i == N or x > T: return stk.append('+') rec(i + 1, x + A[i]) stk.pop() stk.append('*') rec(i + 1, x * A[i]) stk.pop() visited.add((i, x)) rec(1, A[0])