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. printf()函数的参数和制表符

    · 参数 · 控制符 · 转义序列 printf("这是第们学习的第4课"); printf("12345\n6789"); \n  换行 \r  回车键 \b ...

  2. Hive介绍、安装(转)

    1.Hive介绍 1.1 Hive介绍 Hive是一个基于Hadoop的开源数据仓库工具,用于存储和处理海量结构化数据.它是Facebook 2008年8月开源的一个数据仓库框架,提供了类似于SQL语 ...

  3. iOS-OC-基本控件之UITextField

    UITextField IOS开发中必不可少的基本控件,本文主要是列出常用的属性及方法(注XCode版本为7.2) 文本框,可以理解为输入框或者显示框,即用户可以往里面输入文字或图片,可以输入当然也可 ...

  4. Jmeter测试JDBC

    Datebase Driver class Database URL MySQL com.mysql.jdbc.Driver jdbc:mysql://host:port/{dbname} Postg ...

  5. openfire 服务器名称:后面的黄色叹号

    然后点击重新获取证书,然后重新启动服务,问题解决!

  6. DOM - EventListener 句柄操作

          <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" c ...

  7. js获取url参数值(HTML之间传值)

    <h3>未设置设备: <a href="javascript:addTab('设备列表','PKE_DeviceContent/PKE_DeviceContent.aspx ...

  8. ASP.NET MVC中ViewData、ViewBag和TempData

    1.ViewData 1.1 ViewData继承了IDictionary<string, object>,因此在设置ViewData属性时,传入key必须要字符串型别,value可以是任 ...

  9. Freemarker遍历map

    map的键尽量是字符串或者数字类型: <#if map?exists> <#list map?keys as key> ${key}---${map[key]} </#l ...

  10. cordova

    cordova 1.安装 nodejs => node -v2.安装 npm install -g cordova => cordova -v3.安装 jdk 环境变量:(系统变量) 新建 ...