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. 复习宝典之Maven项目管理

    查看更多宝典,请点击<金三银四,你的专属面试宝典> 第二章:Maven项目管理 Maven是基于项目对象模型(POM project object model),可以通过一小段描述信息(配 ...

  2. window下pip install Scrapy报错解决方案

    1.首先打开https://www.lfd.uci.edu/~gohlke/pythonlibs/#twisted,找到对应版本的Twisted并下载到你的文件夹. 2.利用pip install命令 ...

  3. Linux 只显示目录或者文件方法

    ls 参数 -a 表示显示所有文件,包含隐藏文件-d 表示显示目录自身的属性,而不是目录中的内容-F 选项会在显示目录条目时,在目录后加一个/ 只显示目录 方法一: find . -type d -m ...

  4. 基于jquery,ajax请求及自我终止的函数封装。

    场景描述: 在我们平时的开发过程中,经常会遇到这样的情况.在搜索功能中进行模糊搜索或者联想关联. 这就要我们每次对输入框中的数据进行改动时,都要发送一次请求.当在短时间内多次操作改动时,问题就出现了. ...

  5. 数据库5.7-jdbc版本8.0.12驱动连接

    现在版本的jdbc连接方式和原来不一样了, 假如你使用String driver = "com.mysql.jdbc.Driver"; 会抛出错误: Loading class ` ...

  6. python 视频配音、剪辑

    一.FFmpeg的使用 首先下载FFmpeg然后将FFmpeg添加到环境路径中.运行cmd 输入ffmpeg无报错表示成功. 二.python中的使用 在python中执行cmd命令需要调用subpr ...

  7. s3c2440串口详解

    一.UART原理说明 通用异步收发器简称UART(Universal Asynchronous Receiver/Transmitter),它用来传输串行数据:发送数据时,CPU将并行数据写入UART ...

  8. 请求报文的方法及get与post的区别

    请求报文的方法及get与post的区别 请求的起始以方法作为开始,方法用来告诉服务器要如何做. 在开发中通常有两种请求方式. get方式: 是以实体的方式得到由请求 URI 所指定资源的信息,如果请求 ...

  9. 20145207 myeclipse测试

    实验博客  

  10. 20145234黄斐《Java程序设计》第八周学习总结

    教材学习内容总结 第十五章部分 - 通用API 通用API 日志: 日志对信息安全意义重大,审计.取证.入侵检测等都会用到日志信息 日志API Logger: 注意无法使用构造方法生成Logger对象 ...