Description

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

input output
1
2
3
-5

解题思路:三个数之间构成一个数学式,中间只能有两个运算符,既然要求数学式的最小值当然不能出现加法运算符了,实际上就有两种情况罢了,第二个运算符是减号还是乘号,取最小值。

#include<stdio.h>
#include<algorithm>
using namespace std;
int main()
{
int i,sum1,sum2;
int a[];
for(i=;i<;i++)
{
scanf("%d",&a[i]);
}
sort(a,a+);
sum1=a[]-a[]-a[];
sum2=a[]-a[]*a[];
printf("%d\n",min(sum1,sum2));
return ;
}

Simple Expression的更多相关文章

  1. ural 2066. Simple Expression

    2066. Simple Expression Time limit: 1.0 secondMemory limit: 64 MB You probably know that Alex is a v ...

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

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

  3. Expression Tree Basics 表达式树原理

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

  4. Evaluation of Expression Tree

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

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

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

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

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

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

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

  8. Basic Calculator II

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

  9. Chrome-Console( Command Line API Reference)

    来源于:https://developers.google.com/web/tools/chrome-devtools/console/command-line-reference The Comma ...

随机推荐

  1. postman中 form-data、x-www-form-urlencoded、raw、binary的区别【转】

    链接:https://blog.csdn.net/wangjun5159/article/details/47781443 1.form-data: 就是http请求中的multipart/form- ...

  2. 数据库与python的连接

    db=web.database( dbn="mysql", host="localhost", port=3306, user="root" ...

  3. 字符编码ascii、unicode、utf-­‐8、gbk 的关系

    ASIIC码: 计算机是美国人发明和最早使用的,他们为了解决计算机处理字符串的问题,就将数字字母和一些常用的符号做成了一套编码,这个编码就是ASIIC码.ASIIC码包括数字大小写字母和常用符号,一共 ...

  4. JS DOM 1

    接触JS也有快一个月了,现在来总结一下看过的书,一本本总结,之后再融会贯通,也许更有助于学习.废话不多说,现在看的是<JavaScript DOM编程艺术>,该书挺薄的,不太会望而生畏,( ...

  5. hql返回数值

    public int getCountUser() throws ParseException { Session hSession = sessionFactory.getCurrentSessio ...

  6. 关于php中数字0与其他变量的相等判断

    在实践过程中,经常需要做`==`判断,有时候会把0当做false一样用,但是0和false在用来做比较的时候还是不一样的, false false==0 等于true false=='0' 等于tru ...

  7. CSS翻转小效果

    CSS3翻转显示另外一张图: 1.backface-visibility:hidden;背面不可见 2.transform:rotate();旋转 (可以把图片换成本地图片看一下效果) <!DO ...

  8. Python学习1——关于变量

    在python中,使用变量之前不需要声明变量的数据类型, 但是,使用变量前,必须要先对变量进行赋值: 例: num01 += 100 print('num01') 上述例子中,表示的意思是 num01 ...

  9. Python学习:8.小项目之登录注册验证

    简介 本次项目登录注册验证是对之前学习知识点的加深学习,这次项目的练习的知识点有函数.判断语句.循环语句.文件操作等. 项目流程 运行代码之后,输出登录或者注册选项. 当选择登录之后,输入用户名密码, ...

  10. Django中的模型继承

    1.使用最原始的方式继承 class Animal(models.Model): name = models.CharField(max_length=20) age = models.Integer ...