結果
問題 | No.10 +か×か |
ユーザー | szkhts |
提出日時 | 2020-10-10 11:24:51 |
言語 | Python3 (3.11.6 + numpy 1.26.0 + scipy 1.11.3) |
結果 |
RE
|
実行時間 | - |
コード長 | 706 bytes |
コンパイル時間 | 98 ms |
コンパイル使用メモリ | 10,796 KB |
実行使用メモリ | 8,752 KB |
最終ジャッジ日時 | 2023-09-27 21:14:02 |
合計ジャッジ時間 | 7,274 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge15 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 17 ms
8,312 KB |
testcase_01 | AC | 16 ms
8,200 KB |
testcase_02 | AC | 15 ms
8,368 KB |
testcase_03 | RE | - |
testcase_04 | RE | - |
testcase_05 | TLE | - |
testcase_06 | -- | - |
testcase_07 | -- | - |
testcase_08 | -- | - |
testcase_09 | -- | - |
testcase_10 | -- | - |
testcase_11 | -- | - |
ソースコード
def calculate(count, num, gross, op): if op == '+': dp[num + gross] = dp[gross] + '+' gross += num else: dp[num * gross] = dp[gross] + '*' gross *= num if count >= N - 1: return if dp[total] == '' or len(dp[total]) < N - 1: calculate(count + 1, nums[count + 1], gross, '+') if dp[total] == '' or len(dp[total]) < N - 1: calculate(count + 1, nums[count + 1], gross, '*') N = int(input()) total = int(input()) nums = list(map(int, input().split())) dp = ['' for i in range(10000)] calculate(1, nums[1], nums[0], '+') if dp[total] == '' or len(dp[total]) < N - 1: calculate(1, nums[1], nums[0], '*') print(dp[total])