結果
| 問題 |
No.10 +か×か
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-10-10 11:24:51 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 706 bytes |
| コンパイル時間 | 83 ms |
| コンパイル使用メモリ | 12,544 KB |
| 実行使用メモリ | 16,000 KB |
| 最終ジャッジ日時 | 2024-07-20 15:46:27 |
| 合計ジャッジ時間 | 6,835 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 3 RE * 2 TLE * 1 -- * 6 |
ソースコード
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])