2066. Simple Expression

Time limit: 1.0 second
Memory limit: 64 MB
You probably know that Alex is a very serious mathematician and he likes to solve serious problems. This is another problem from Alex.
You are given three nonnegative integers abc. You have to arrange them in some order and put +, − or × signs between them to minimize the outcome of the resulting expression. You are not allowed to use unary minus and parentheses in the expression. There must be exactly one sign between every pair of neighbouring numbers. You should use standard order for performing operations (multiplication first, addition and subtraction then).

Input

There are three lines with one integer in each line. The numbers are arranged in non-decreasing order (0 ≤ a ≤ b ≤ c ≤ 100).

Output

Print one number — the minimal outcome.

Sample

input output
1
2
3
-5
Problem Author: Kirill Borozdin
Problem Source: Ural Regional School Programming Contest 2015
Difficulty: 54
 
 #include <iostream>
using namespace std;
typedef long long LL;
int main()
{
ios::sync_with_stdio();
LL a, b, c;
cin >> a >> b >> c;
LL ans = a + b + c;
ans = min(ans, a + b - c);
ans = min(ans, a + b * c);
ans = min(ans, a * b + c);
ans = min(ans, a * b - c);
ans = min(ans, a * b * c);
ans = min(ans, a - b + c);
ans = min(ans, a - b - c);
ans = min(ans, a - b * c);
cout << ans << endl;
return ;
}

ural 2066. Simple Expression的更多相关文章

  1. URAL 2066 Simple Expression (水题,暴力)

    题意:给定三个数,让你放上+-*三种符号,使得他们的值最小. 析:没什么好说的,全算一下就好.肯定用不到加,因为是非负数. 代码如下: #pragma comment(linker, "/S ...

  2. Simple Expression

    Description You probably know that Alex is a very serious mathematician and he likes to solve seriou ...

  3. Ural 2003: Simple Magic(数论&思维)

    Do you think that magic is simple? That some hand-waving and muttering incomprehensible blubber is e ...

  4. Expression Tree Basics 表达式树原理

    variable point to code variable expression tree data structure lamda expression anonymous function 原 ...

  5. Evaluation of Expression Tree

    Evaluation of Expression Tree Given a simple expression tree, consisting of basic binary operators i ...

  6. ElasticSearch 5学习(2)——Kibana+X-Pack介绍使用(全)

    Kibana是一个为 ElasticSearch 提供的数据分析的 Web 接口.可使用它对日志进行高效的搜索.可视化.分析等各种操作.Kibana目前最新的版本5.0.2,回顾一下Kibana 3和 ...

  7. [LeetCode] Basic Calculator II 基本计算器之二

    Implement a basic calculator to evaluate a simple expression string. The expression string contains ...

  8. [LeetCode] Basic Calculator 基本计算器

    Implement a basic calculator to evaluate a simple expression string. The expression string may conta ...

  9. Basic Calculator II

    Implement a basic calculator to evaluate a simple expression string. The expression string contains ...

随机推荐

  1. vector reserve与resize区别

    vector 的reserve增加了vector的capacity,但是它的size没有改变!而resize改变了vector的capacity同时也增加了它的size!原因如下:reserve是容器 ...

  2. 1 mysql的安装

    win10 总之前期的步骤大概有:1下载安装:2 安装好后配置环境变量:3:登陆数据库 1:安装 mysql有安装版和直接解压就可以用的,据说大神都是安装的直接解压的,但鉴于自己是小白,就整了个安装版 ...

  3. MVC学习笔记---各种上下文context

    0  前言 AspNet MVC中比较重要的上下文,有如下: 核心的上下文有HttpContext(请求上下文),ControllerContext(控制器上下文) 过滤器有关有五个的上下文Actio ...

  4. Delphi集合的用法

    参考:http://www.cnblogs.com/doit8791/archive/2012/08/17/2644859.html 集合是Pascal特有的数据类型,在Visual Basic.C/ ...

  5. 【131202】SQL

    SELECT TOP 2 * FROM Persons SELECT *FROM PersonsWHERE ROWNUM <= 5   SELECT * FROM Persons WHERE C ...

  6. Spring中的jar包详解

    下面给大家说说spring众多jar包的特点吧,无论对于初学spring的新手,还是spring高手,这篇文章都会给大家带来知识上的收获,如果你已经十分熟悉本文内容就当做一次温故知新吧.spring. ...

  7. 机器学习系列:python

    工欲善其事,必先利其器!        机器学习的理论需要有编程语言才能得以实现,我选择 python 作为编程语言,网络上有篇不错的教程:python 初级教程:入门详解. 转载自http://ww ...

  8. 攻城狮在路上(叁)Linux(十一)--- 用户与用户组、文件权限、目录配置

    一.用户与用户组: 3个概念:文件所有者(user).用户组(group).其他人(others). /etc/passwd  <==存放所有的用户名 /etc/shadow  <==存放 ...

  9. 在source insight中集成astyle

    转自:http://www.cnblogs.com/xuxm2007/archive/2013/04/06/3002390.html 好吧,我有代码格式的强迫症,代码不整齐,我看的都头疼,之前一直喜欢 ...

  10. git分支使用

    1.查看远程服务器分支 git branch -a 2.查看本地分支 git branch 3.切换分支 git checkout master 4.删除远程分支 git push origin :b ...