結果
問題 | No.10 +か×か |
ユーザー |
![]() |
提出日時 | 2014-11-10 22:47:08 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 561 ms / 5,000 ms |
コード長 | 637 bytes |
コンパイル時間 | 83 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 50,012 KB |
最終ジャッジ日時 | 2024-12-14 15:25:32 |
合計ジャッジ時間 | 2,402 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 12 |
ソースコード
import sys #sys.setrecursionlimit(n) import heapq import re import bisect import random import math import itertools from collections import defaultdict, deque from copy import deepcopy n = int(input()) total = int(input()) a = [int(i) for i in input().split()] ans = [''] * 50 memo = defaultdict(lambda:defaultdict(int)) def solve(i, t): if t == total and i == n - 1: print(''.join(ans)) sys.exit(0) if i >= n - 1 or t > total or memo[i][t]: return ans[i] = '+' solve(i + 1, t + a[i + 1]) ans[i] = '*' solve(i + 1, t * a[i + 1]) memo[i][t] = True return t = a[0] solve(0, t)