当前位置:网站首页>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
边栏推荐
- NPM run dev start project error document is not defined
- bat脚本学习(一)
- Sparkshuffle process and Mr shuffle process
- Depth first traversal (DFS) and breadth first traversal (BFS)
- Leetcode learning records (starting from the novice village, you can't kill out of the novice Village) ---1
- 在Pi和Jetson nano上运行深度网络,程序被Killed
- Intelligent online customer service system source code Gofly development log - 2 Develop command line applications
- JS learning notes OO create suspicious objects
- 用aardio写一个旋转验证码标注小工具
- Why rdd/dataset is needed in spark
猜你喜欢
Shell product written examination related
make menuconfig出现recipe for target ‘menuconfig‘ failed错误
guava:Collections.unmodifiableXXX创建的collection并不immutable
AI 企业多云存储架构实践 | 深势科技分享
The golden age of the U.S. technology industry has ended, and there have been constant lamentations about chip sales and 30000 layoffs
一行代码可以做些什么?
GPS从入门到放弃(十三)、接收机自主完好性监测(RAIM)
华为在多个行业同时出击,吓人的技术让欧美企业瑟瑟发抖
Earned value management EVM detailed explanation and application, example explanation
Basic introduction of figure
随机推荐
guava:Collections.unmodifiableXXX创建的collection并不immutable
ViT论文详解
【sciter Bug篇】多行隐藏
LeetCode学习记录(从新手村出发之杀不出新手村)----1
ROS error: could not find a package configuration file provided by "move_base“
Five wars of Chinese Baijiu
Realization of epoll reactor model
GPS from entry to abandonment (XIV), ionospheric delay
Reptile practice (V): climbing watercress top250
GPS从入门到放弃(十八)、多路径效应
Digital transformation takes the lead to resume production and work, and online and offline full integration rebuilds business logic
抖音将推独立种草App“可颂”,字节忘不掉小红书?
GPS从入门到放弃(十三)、接收机自主完好性监测(RAIM)
[Chongqing Guangdong education] Tianjin urban construction university concrete structure design principle a reference
npm run dev启动项目报错 document is not defined
GPS du début à l'abandon (XIII), surveillance autonome de l'intégrité du récepteur (raim)
Michael smashed the minority milk sign
AI 企业多云存储架构实践 | 深势科技分享
关于程序员的职业操守,从《匠艺整洁之道》谈起
mysql根据两个字段去重