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. Linux Shell多命令执行

    有三种: :只是顺序执行,命令之间没有任何关联,不相互影响.如  ls;date;cd /etc/ 如,创建100M的文件. && 命令之间有关系,只有前一条命令正确执行才会执行下面一 ...

  2. XMPP框架下微信项目总结(8)图片发送

    前言:“图片”发送和“聊天文本”都是通过模块发起的成为:“消息模块”(反正传递的都是字符串) 发送原理:     1 current客户端获取本地图片 2 xmpp发送“字符串”(为什么是字符串?1: ...

  3. 自定义UIDatePikerView

    1.添加文件GoYearMonthDayPickerView.h .m .xib.NSDate+Helper.h .m.iCarousel.h .m 2.在Lable上显示日期 UILabel *ag ...

  4. ios 弹出键盘 视图向上平移

    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(keyboardwillAppear:) name:U ...

  5. 20145206邹京儒《Java程序设计》第6周学习总结

    20145206 <Java程序设计>第6周学习总结 教材学习内容总结 第十章 输入/输出 Java将输入/输出抽象化为串流,数据有来源及目的地,衔接两者的是串流对象. 从应用程序角度来看 ...

  6. 重温WCF之WCF传输安全(十三)(1)前期准备之证书制作(转)

    转载地址:http://www.cnblogs.com/lxblog/archive/2012/09/12/2682372.html 一.WCF中的安全方式 说到安全就会涉及到认证,消息一致性和机密性 ...

  7. MVC:Control与View传值

    MVC页面传值的方式主要有三种: 第一种: 采用ViewData.采用键值对的方式,ViewData存储的是一个object类型,传到view层需要强类型转换:使用起来类似于字典集合模式: ViewD ...

  8. 安装oracle 10g RAC执行的几个脚本说明

    1,/u01/app/oracle/oraInventory/orainstRoot.sh 脚本 #!/bin/sh if [ -d "/etc" ]; then /etc; fi ...

  9. Linux环境下使用perl编写CGI(httpd)

    例子1: /var/www/cgi-bin/hello.cgi #!/usr/bin/perl print "Content-type: text/html\n\n"; print ...

  10. RAC NTP/CTSS

    本文總結主要參考: http://blog.itpub.net/23135684/viewspace-759693/ http://www.happyworld.net.cn/post/6.html ...