cf479A Expression
Petya studies in a school and he adores Maths. His class has been studying arithmetic expressions. On the last class the teacher wrote three positive integers a, b, c on the blackboard. The task was to insert signs of operations '+' and '*', and probably brackets between the numbers so that the value of the resulting expression is as large as possible. Let's consider an example: assume that the teacher wrote numbers 1, 2 and 3 on the blackboard. Here are some ways of placing signs and brackets:
- 1+2*3=7
- 1*(2+3)=5
- 1*2*3=6
- (1+2)*3=9
Note that you can insert operation signs only between a and b, and between b and c, that is, you cannot swap integers. For instance, in the given sample you cannot get expression (1+3)*2.
It's easy to see that the maximum value that you can obtain is 9.
Your task is: given a, b and c print the maximum value that you can get.
The input contains three integers a, b and c, each on a single line (1 ≤ a, b, c ≤ 10).
Print the maximum value of the expression that you can obtain.
1
2
3
9
2
10
3
60
div2的A啊……sb模拟
六种情况搞来搞去
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<set>
#include<map>
#include<ctime>
#define LL long long
#define inf 0x7ffffff
#define pa pair<int,int>
#define pi 3.1415926535897932384626433832795028841971
using namespace std;
LL a,b,c,ans;
inline LL read()
{
LL x=,f=;char ch=getchar();
while(ch<''||ch>''){if(ch=='-')f=-;ch=getchar();}
while(ch>=''&&ch<=''){x=x*+ch-'';ch=getchar();}
return x*f;
}
int main()
{
a=read();b=read();c=read();
ans=a+b+c;
ans=max(ans,a+b*c);
ans=max(ans,a*b+c);
ans=max(ans,(a+b)*c);
ans=max(ans,a*(b+c));
ans=max(ans,a*b*c);
printf("%lld\n",ans);
}
cf479A
cf479A Expression的更多相关文章
- AutoMapper:Unmapped members were found. Review the types and members below. Add a custom mapping expression, ignore, add a custom resolver, or modify the source/destination type
异常处理汇总-后端系列 http://www.cnblogs.com/dunitian/p/4523006.html 应用场景:ViewModel==>Mode映射的时候出错 AutoMappe ...
- OpenCASCADE Expression Interpreter by Flex & Bison
OpenCASCADE Expression Interpreter by Flex & Bison eryar@163.com Abstract. OpenCASCADE provide d ...
- Expression Blend创建自定义按钮
在 Expression Blend 中,我们可以在美工板上绘制形状.路径和控件,然后修改其外观和行为,从而直观地设计应用程序.Button按钮也是Expression Blend最常用的控件之一,在 ...
- [C#] C# 知识回顾 - 表达式树 Expression Trees
C# 知识回顾 - 表达式树 Expression Trees 目录 简介 Lambda 表达式创建表达式树 API 创建表达式树 解析表达式树 表达式树的永久性 编译表达式树 执行表达式树 修改表达 ...
- Could not evaluate expression
VS15 调试变量不能显示值,提示:Could not evaluate expression 解决办法: 选择"在调试时显示运行以单击编辑器中的按钮"重启VS即可. 可参考:Vi ...
- 使用Expression实现数据的任意字段过滤(1)
在项目常常要和数据表格打交道. 现在BS的通常做法都是前端用一个js的Grid控件, 然后通过ajax的方式从后台加载数据, 然后将数据和Grid绑定. 数据往往不是一页可以显示完的, 所以要加分页: ...
- 使用Expression实现数据的任意字段过滤(2)
上一篇<使用Expression实现数据的任意字段过滤(1)>, 我们实现了通过CriteriaCollectionHandler对象来处理集合数据过滤.通过适当的扩展, 应该可以满足一般 ...
- React Native JSX value should be expression or a quoted JSX text.
问题描述: 我在使用props时候, 我的写法是这样的 ... <View> <Person name='john' age=32 gender=true></Pers ...
- [LeetCode] Ternary Expression Parser 三元表达式解析器
Given a string representing arbitrarily nested ternary expressions, calculate the result of the expr ...
随机推荐
- HDOJ-1019 Least Common Multiple
http://acm.hdu.edu.cn/showproblem.php?pid=1019 题意:给出n个数,求它们的最小公倍数 对于n个数,它们的最小公倍数等于[前n-1个数的最小公倍数和第n个数 ...
- c++编程碰到的奇怪问题与解决
今天写一个工具,调试过程中莫名其妙崩溃,类某些成员变量指针很奇怪,为0x00003001.最后检查的结果居然是这样的: 文件class1.h: class1 { int a; int b; } 文件: ...
- EffectiveC#12,13,14--成员初始化
1.在一个类里声明变量的同时,直接创建实例值.包括静态的和实例的变量 例:object m_o = new object(); 如下情况时不建议这么做:第一种 值类型. int i=new int() ...
- Github错误:Failed to publish this branch
转自:http://jingpin.jikexueyuan.com/article/34632.html 今天弄github的时候,客户端一直出现error to publish this branc ...
- Xcode 中添加 .pch文件
1 新建工程 2 创建 .pch文件 3 在setting里面进行设置:
- _BLOCK_TYPE_IS_VALID错误
_BLOCK_TYPE_IS_VALID宏用来检测这个内存块在当前堆上是否有效,但是这里的指针是一个临时变量,临时变量是在栈上分配的,函数清理栈时会自动回收这些内存,程序员无需管理. new 和 ma ...
- uva 12100 Printer Queue
The only printer in the computer science students' union is experiencing an extremely heavy workload ...
- (转) Eclipse - Python - Installation of PyDev with a Python Hello World tutorial
Once you finished your installation of Python on your Windows OS, GNU/Linux or Mac OS, let me tell ...
- (原)下载pubFig的python代码
转载请注明出处: http://www.cnblogs.com/darkknightzh/p/5715305.html pubFig数据库网址: http://www.cs.columbia.edu/ ...
- numpy库:常用基本
numpy 本文主要列出numpy模块常用方法 大部分内容来源于网络,而后经过自己的一点思考和总结,如果有侵权,请联系我 我是一名初学者,有哪些地方有错误请留言,我会及时更改的 创建矩阵(采用ndar ...