CF55B.Smallest number
普及/提高-
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Recently, Vladimir got bad mark in algebra again. To avoid such unpleasant events in future he decided to train his arithmetic skills. He wrote four integer numbers a, b, c, d on the blackboard. During each of the next three minutes he took two numbers from the blackboard (not necessarily adjacent) and replaced them with their sum or their product. In the end he got one number. Unfortunately, due to the awful memory he forgot that number, but he remembers four original numbers, sequence of the operations and his surprise because of the very small result. Help Vladimir remember the forgotten number: find the smallest number that can be obtained from the original numbers by the given sequence of operations.
最近,弗拉基米尔的代数考试又考砸了。为了避免将来再发生这种不愉快的事情,他决定训练自己的算术能力。他在黑板上写下了四个整数 a、b、c、d。在接下来的三分钟里,他每分钟从黑板上任取两个数(不一定相邻),并将它们替换为它们的和或积。最终,黑板上只剩下一个数。不幸的是,由于记忆力极差,他忘记了这个最终结果,但他还记得最初的四个数、操作的顺序,以及自己因最终结果非常小而感到惊讶。请帮助弗拉基米尔找回那个被遗忘的数:在给定的操作序列下,求出由原始四个数所能得到的最小可能值。
输入格式
First line contains four integers separated by space: 0 ≤ a, b, c, d ≤ 1000 — the original numbers. Second line contains three signs ('+' or '*' each) separated by space — the sequence of the operations in the order of performing. ('+' stands for addition, '*' — multiplication)
第一行包含四个由空格分隔的整数:0 ≤ a, b, c, d ≤ 1000 — 原始数字。
第二行包含三个由空格分隔的运算符(每个为 '+' 或 '*')— 表示按执行顺序排列的运算序列。('+' 表示加法,'*' 表示乘法)
输出格式
Output one integer number — the minimal result which can be obtained.
Please, do not use %lld specificator to read or write 64-bit integers in C++. It is preffered to use cin (also you may use %I64d).
输出一个整数——可获得的最小结果。
请注意,在 C++ 中不要使用 %lld 格式说明符来读取或写入 64 位整数。推荐使用 cin(也可以使用 %I64d)。
输入输出样例
输入#1
1 1 1 1 + + *
输出#1
3
输入#2
2 2 2 2 * * +
输出#2
8
输入#3
1 2 3 4 * + +
输出#3
9
输入解题思路,AI测评打分。不知道怎么写?