当前位置:网站首页>Codeforces Round #274 (Div. 2) –A Expression
Codeforces Round #274 (Div. 2) –A Expression
2022-07-06 21:58:00 【Full stack programmer webmaster】
Hello everyone , I meet you again , I'm the king of the whole stack .
Topic links :Expression
Expression
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
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.
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
General meaning :a, b, c Three numbers . Among the three numbers , Insert “+” and “*” Any two combinations of operators , Find the maximum value of the expression composed of energy .( Can use brackets )
Their thinking : Nothing to say. . Direct violence , All in all 6 Combinations of .
AC Code :
#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;
}
Copyright notice : this paper sxk Original article . Reprint this article , Please add a link ^_^
Publisher : Full stack programmer stack length , Reprint please indicate the source :https://javaforall.cn/117058.html Link to the original text :https://javaforall.cn
边栏推荐
- Kohana 数据库
- Redistemplate common collection instructions opsforset (V)
- Depth first traversal (DFS) and breadth first traversal (BFS)
- 红杉中国,刚刚募资90亿美元
- [asp.net core] set the format of Web API response data -- formatfilter feature
- ROS error: could not find a package configuration file provided by "move_base“
- ViT论文详解
- GPS从入门到放弃(十五)、DCB差分码偏差
- The role of applicationmaster in spark on Yan's cluster mode
- 设置状态栏样式Demo
猜你喜欢
Make menuconfig has a recipe for target 'menuconfig' failed error
Shake Sound poussera l'application indépendante de plantation d'herbe "louable", les octets ne peuvent pas oublier le petit livre rouge?
Why is the cluster mode of spark on Yan better than the client mode
Why rdd/dataset is needed in spark
ViT论文详解
GPS du début à l'abandon (XIII), surveillance autonome de l'intégrité du récepteur (raim)
C# 如何在dataGridView里设置两个列comboboxcolumn绑定级联事件的一个二级联动效果
Numpy download and installation
Sequoia China, just raised $9billion
红杉中国,刚刚募资90亿美元
随机推荐
Realization of epoll reactor model
Leveldb source code analysis series - main process
保存和检索字符串
jvm:大对象在老年代的分配
Reset Mikrotik Routeros using netinstall
1292_ Implementation analysis of vtask resume() and xtask resume fromisr() in freeros
[asp.net core] set the format of Web API response data -- formatfilter feature
Run the deep network on PI and Jetson nano, and the program is killed
PostgreSQL 安装gis插件 CREATE EXTENSION postgis_topology
Sql: stored procedures and triggers - Notes
【sciter】: 基于 sciter 封装通知栏组件
LeetCode:1189. The maximum number of "balloons" -- simple
PostgreSQL modifies the password of the database user
在Pi和Jetson nano上运行深度网络,程序被Killed
Microsoft technology empowerment position - February course Preview
What is the difference between animators and animators- What is the difference between an Animator and an Animation?
Sequoia China, just raised $9billion
JPEG2000-Matlab源码实现
Leetcode topic [array] -118 Yang Hui triangle
搜素专题(DFS )