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. 执行SQL查询导致磁盘耗尽故障演示

            a fellow in IMG wechat group 2 met an error about running out of disk space when using MySQL ...

  2. JSP/Servlet开发——第七章 Servel基础

    1.Servlet简介: ●Servlet是一个符合特定规范的 JAVA 程序 , 是一个基于JAVA技术的Web组件. ●Servlet允许在服务器端,由Servlet容器所管理,用于处理客户端请求 ...

  3. jQuery DOM/属性/CSS操作

    jQuery DOM 操作 创建元素 只需要把DOM字符串传入$方法即可返回一个 jQuery 对象 var obj = $('<div class="test">&l ...

  4. mysql的char,varchar,text,blob

    mysql的char,varchar,text,blob是几个有联系但是有有很大区别的字段类型,这算是mysql的基础吧,可是基础没有学好,恶补一下. 先简单的总结一下: char:定长,最大255个 ...

  5. Prim算法堆优化

    #include <stdio.h> #include <string.h> #include <stdlib.h> #include <ctype.h> ...

  6. jxls-2.x导出excel入门——基本操作

    之前随笔使用的是1.x的比较古老的版本了,已经不再维护,接下来使用较新的2.x的版本进行导出 之前一直按照其他的博客与官网的随笔进行导出,发现一直报错,后面更换了POI的版本为3.16(因为jxls也 ...

  7. logger 配置文件详解

    Logback配置文件详解 Logback,Java 日志框架. Logback 如何加载配置的 logback 首先会查找 logback.groovy 文件 当没有找到,继续试着查找 logbac ...

  8. 【CF613D】Kingdom and its Cities(虚树,动态规划)

    [CF613D]Kingdom and its Cities(虚树,动态规划) 题面 洛谷 CF 翻译洛谷上有啦 题解 每次构建虚树,首先特判无解,也就是关键点中存在父子关系. 考虑\(dp\),设\ ...

  9. 北京Uber优步司机奖励政策(11月9日~11月15日)

    用户组:人民优步“关羽组”(适用于11月9日-11月15日)奖励政策: 滴快车单单2.5倍,注册地址:http://www.udache.com/ 如何注册Uber司机(全国版最新最详细注册流程)/月 ...

  10. CF 1042 F. Leaf Sets

    F. Leaf Sets http://codeforces.com/contest/1042/problem/F 题意: 将所有的叶子节点分配到尽量少的集合,一个可行的集合中两两叶子节点的距离< ...