博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
周赛-Expression 分类: 比赛 20...
阅读量:4582 次
发布时间:2019-06-09

本文共 1878 字,大约阅读时间需要 6 分钟。

A. Expression

time limit per test1 second
memory limit per test256 megabytes
inputstandard input
outputstandard output
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.

Input

The input contains three integers a, b and c, each on a single line (1 ≤ a, b, c ≤ 10).

Output

Print the maximum value of the expression that you can obtain.

Sample test(s)

input
1
2
3
output
9
input
2
10
3
output
60
枚举飘过

#include 
#include
#include
#include
#include
#include
#include
#include
#include
#include
#define LL long long#define RR freopen("output.txt","r",stdoin)#define WW freopen("input.txt","w",stdout)using namespace std;const int MAX = 100100;int main(){ int a,b,c; int Max; while(~scanf("%d %d %d",&a,&b,&c)) { Max=0; Max=max(Max,a+b+c); Max=max(Max,a*(b+c)); Max=max(Max,(a+b)*c); Max=max(Max,a*b*c); Max=max(Max,a*b+c); Max=max(Max,a+b*c); printf("%d\n",Max); } return 0;}

版权声明:本文为博主原创文章,未经博主允许不得转载。

转载于:https://www.cnblogs.com/juechen/p/4721940.html

你可能感兴趣的文章
TJU Problem 2857 Digit Sorting
查看>>
C# 修饰符
查看>>
java中使用session的一些细节
查看>>
浏览器输入服务器端口号来访问html网页
查看>>
hdu 6435 CSGO(最大曼哈顿距离)
查看>>
logback框架之——日志分割所带来的潜在问题
查看>>
链路追踪工具之Zipkin学习小记
查看>>
iOS中通讯录的开发
查看>>
怎么让table中的<td>内容向上对齐
查看>>
[Java] 遍历HashMap和HashMap转换成List的两种方式
查看>>
mongodb
查看>>
LeetCode 46. Permutations
查看>>
jmeter- 性能测试3:聚合报告(Aggregate Report )
查看>>
JavaScript高级程序设计---学习笔记(二)
查看>>
vim 插件的学习
查看>>
Uncaught SyntaxError: Unexpected token ILLEGAL
查看>>
一个预处理定义的问题
查看>>
ANDROID L——Material Design综合应用(Demo)
查看>>
自我介绍以及关于软件工程的问题
查看>>
struts (一)
查看>>