yukicoder-10

从 Trac 迁移的文章

这是从旧校内 Wiki 迁移的文章,可能存在一些样式问题,您可以向 memset0 反馈。

原文章内容如下:

{{{
#!html
<script type="text/x-mathjax-config">MathJax.Hub.Config({tex2jax: {inlineMath: [['$','$'], ['\\(','\\)']]}});</script>
<script type="text/javascript" async src="http://10.71.10.90/sfiction/tool/MathJax/MathJax-master/MathJax.js?config=TeX-MML-AM_CHTML"></script>
<style>
.input, pre {
    display: block;
    padding: 9.5px;
    margin: 0 0 10px;
    font-size: 13px;
    line-height: 1.42857143;
    color: #333;
    word-break: break-all;
    word-wrap: break-word;
    background-color: #f5f5f5;
    border: 1px solid #ccc;
    border-radius: 4px;
}
</style>
}}}

== [https://yukicoder.me/problems/no/10 No.10 +か×か] ==

=== Description ===

{{{
#!html
<p>有$N$个数排成一列,第$i$个数是$A_i$。你可以在相邻两个数之间插入'+'或者'*',使得这个表达式最后等于$Total$。这里假设'+'和'*'优先级一样,从左往右开始计算。例如$1+2*10+1=((1+2)*10)+1=31$。</p>
}}}

=== Input ===

{{{
#!html
<p class="input">
$N$<br>
$Total$<br>
$A_1$ $A_2$ $\dots$ $A_N$<br>
</p>

<p>$2 \le N \le 50, 1 \le Total \le 100000, 1 \le A_i \le 10$。</p>
}}}

=== Output ===

{{{
#!html
<p>输出字典序最小的方案。</p>
}}}

=== Sample ===

==== Sample 1 ====
输入
{{{
#!html
<pre>
4
31
1 2 10 1
</pre>
}}}
输出
{{{
#!html
<pre>
+*+
</pre>
}}}

==== Sample 2 ====
输入
{{{
#!html
<pre>
3
6
2 3 1
</pre>
}}}
输出
{{{
#!html
<pre>
++
</pre>
}}}

==== Sample 3 ====
输入
{{{
#!html
<pre>
3
2
1 1 2
</pre>
}}}
输出
{{{
#!html
<pre>
**
</pre>
}}}

No.10 +か×か

Description

有$N$个数排成一列,第$i$个数是$A_i$。你可以在相邻两个数之间插入'+'或者'*',使得这个表达式最后等于$Total$。这里假设'+'和'*'优先级一样,从左往右开始计算。例如$1+2*10+1=((1+2)*10)+1=31$。

Input

$N$
$Total$
$A_1$ $A_2$ $\dots$ $A_N$

$2 \le N \le 50, 1 \le Total \le 100000, 1 \le A_i \le 10$。

Output

输出字典序最小的方案。

Sample

Sample 1

输入

4311 2 10 1

输出

+*+
Sample 2

输入

362 3 1

输出

++
Sample 3

输入

321 1 2

输出

**