Codeforces Round #274 (Div. 2) --A Expression
主题链接:Expression
1 second
256 megabytes
standard input
standard 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.
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
大致题意:a, b, c三个数。在三个数中,插入“+” 和“*”运算符的随意两个组合,求能组成的表达式的值得最大值。(能够用括号)
解题思路:没啥说的。直接暴力,总共就6种组合。
AC代码:
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <stdlib.h>
#include <time.h>
using namespace std;
#define INF 0x7fffffff int x[9]; int main()
{
// #ifdef sxk
// freopen("in.txt","r",stdin);
// #endif
int a,b,c;
while(scanf("%d%d%d",&a,&b,&c)!=EOF)
{
x[0] = a + b + c;
x[1] = a + (b * c);
x[2] = a * (b + c);
x[3] = (a + b) * c;
x[4] = (a * b) + c;
x[5] = a * b * c;
sort(x, x+6);
printf("%d\n",x[5]);
}
return 0;
}
版权声明:本文sxk原创文章。转载本文,请添加链接^_^
Codeforces Round #274 (Div. 2) --A Expression的更多相关文章
- codeforces水题100道 第八题 Codeforces Round #274 (Div. 2) A. Expression (math)
题目链接:http://www.codeforces.com/problemset/problem/479/A题意:给你三个数a,b,c,使用+,*,()使得表达式的值最大.C++代码: #inclu ...
- Codeforces Round #274 (Div. 2) 解题报告
题目地址:http://codeforces.com/contest/479 这次自己又仅仅能做出4道题来. A题:Expression 水题. 枚举六种情况求最大值就可以. 代码例如以下: #inc ...
- Codeforces Round #274 (Div. 2)
A http://codeforces.com/contest/479/problem/A 枚举情况 #include<cstdio> #include<algorithm> ...
- Codeforces Round #274 (Div. 1) C. Riding in a Lift 前缀和优化dp
C. Riding in a Lift Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/480/pr ...
- Codeforces Round #274 (Div. 1) B. Long Jumps 数学
B. Long Jumps Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/480/problem/ ...
- Codeforces Round #274 (Div. 1) A. Exams 贪心
A. Exams Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/480/problem/A Des ...
- Codeforces Round #274 (Div. 2)-C. Exams
http://codeforces.com/contest/479/problem/C C. Exams time limit per test 1 second memory limit per t ...
- Codeforces Round #274 Div.1 C Riding in a Lift --DP
题意:给定n个楼层,初始在a层,b层不可停留,每次选一个楼层x,当|x-now| < |x-b| 且 x != now 时可达(now表示当前位置),此时记录下x到序列中,走k步,最后问有多少种 ...
- Codeforces Round #274 (Div. 2) E. Riding in a Lift(DP)
Imagine that you are in a building that has exactly n floors. You can move between the floors in a l ...
随机推荐
- Android平台调用Web Service:螺纹的引入
连接文本 剩下的问题 MainActivity的onCreate方法中假设没有有这段代码: // 强制在UI线程中操作 StrictMode.setThreadPolicy(new StrictMod ...
- MyBatis一级缓存引起的无穷递归
MyBatis一级缓存引起的无穷递归 引言: 最近在项目中参与了一个领取优惠劵的活动,当多个用户领取同一张优惠劵的时候,使用了数据库锁控制并发,起初的设想是:如果多个人同时领一张劵,第一个到达的人领取 ...
- HUNNU11354:Is the Name of This Problem
http://acm.hunnu.edu.cn/online/?action=problem&type=show&id=11354&courseid=0 Problem des ...
- matlab 2014a 改为英文版本号
1. 在 Matlab 的安装目录以下找到例如以下的路径,X:\MATLAB\R2014a\java\jar,当中 X 为安装盘符,这个不用过多解释了,然后找到目录 zh_CN.此目录就是中文界面的语 ...
- UNIX网络编程卷1 server程序设计范式7 预先创建线程,以相互排斥锁上锁方式保护accept
本文为senlie原创.转载请保留此地址:http://blog.csdn.net/zhengsenlie 1.预先创建一个线程池.并让每一个线程各自调用 accept 2.用相互排斥锁代替让每一个线 ...
- python学习笔记之八:迭代器和生成器
一. 迭代器 在前面的笔记中,已经提到过迭代器(和可迭代),这里会对此进行深入讨论.只讨论一个特殊方法---__iter__,这个方法是迭代器规则的基础. 1.1 迭代器规则 迭代的意思是重复做一些事 ...
- IOS开发-通知与消息机制
在多数移动应用中不论什么时候都仅仅能有一个应用程序处于活跃状态.假设其它应用此刻发生了一些用户感兴趣的那么通过通知机制就能够告诉用户此时发生的事情. iOS中通知机制又叫消息机制,其包含两类:一类是本 ...
- Android定义自己的面板共享系统
在Android分享知道有一个更方便的方法.调用的共享面板来分享我们的应用程序的系统.主要实现例如,下面的: public Intent getShareIntent(){ Intent intent ...
- android 如何分析java.lang.IllegalArgumentException: Cannot draw recycled bitmaps异常
这类问题的分析,通常你需要找到bitmap对象已经在那个位置recyle,然后检查代码. 如何定位的位置,其中代码具有对bitmap 目的recyle.能够 Bitmap.java的recycle方法 ...
- HDU 1394 Minimum Inversion Number (数据结构-段树)
Minimum Inversion Number Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java ...