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. uva_11806_Cheerleaders

    In most professional sporting events, cheerleaders play a major role in entertaining the spectators. ...

  2. python字符编码转换说明及深浅copy介绍

    编码说明: 常用编码介绍: ascii 数字,字母 特殊字符. 字节:8位表示一个字节. 字符:是你看到的内容的最小组成单位. abc : a 一个字符. 中国:中 一个字符. a : 0000 10 ...

  3. 第一次使用mpvue的小记

    ​ 昨晚睡前打开了半个月没打开的知乎, 看到了一个专栏文章再见jquery,我的老朋友,突然想到之前github传出,github已经彻底删除jquery,这似乎标志着前端已经完全进入了一个新的时代, ...

  4. Mysql 关于处理NULL值的相关函数和操作符

    操作符 <=> NULL-safe equal. This operator performs an equality comparison like the = operator, bu ...

  5. Vue directive自定义指令+canvas实现H5图片压缩上传-Base64格式

    前言 最近优化项目-手机拍照图片太大,回显速度比较慢,使用了vue的自定义指令实现H5压缩上传base64格式的图片 canvas自定义指令 Vue.directive("canvas&qu ...

  6. LCD驱动程序

    学习目标:熟悉TFT LCD的概念,分层驱动工作原理和程序编写. 一.LCD 概念 1.  显示器数据组织格式 1)一幅图像成为一帧,每帧由多行组成,每行由多个像素组成.每个像素的颜色由若干位表示,对 ...

  7. 成都Uber优步司机奖励政策(1月17日)

    滴快车单单2.5倍,注册地址:http://www.udache.com/ 如何注册Uber司机(全国版最新最详细注册流程)/月入2万/不用抢单:http://www.cnblogs.com/mfry ...

  8. 上海Uber优步司机奖励政策(1月11日~1月17日)

    滴快车单单2.5倍,注册地址:http://www.udache.com/ 如何注册Uber司机(全国版最新最详细注册流程)/月入2万/不用抢单:http://www.cnblogs.com/mfry ...

  9. python字符串格式化符号及转移字符含义

    博文出自鱼C论坛文章 http://bbs.fishc.com/thread-39140-1-1.html

  10. UItraIso 制作ubentu 系统失败

    设备忙,请退出所有正在运行的应用程序,按确定按钮重试. 解决方法: 不要使用UItraIso,不知道为什么一直不行.重启了电脑几次都不行.用Rufus吧 https://rufus.ie/ 注意: r ...