Codeforces Round #274 (Div. 2) –A Expression

Codeforces Round #274 (Div. 2) –A Expression

大家好,又见面了,我是全栈君,今天给大家准备了Idea注册码。

主题链接: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 abc 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 ab and c print the maximum value that you can get.

Input

The input contains three integers ab 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

大致题意: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原创文章。转载本文,请添加链接^_^

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/117058.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • 交互神器 Facebook Origami

    交互神器 Facebook Origami

    2022年3月3日
    40
  • Windows 7 深圳地区社区发布会归来

    Windows 7 深圳地区社区发布会归来

    2021年8月1日
    79
  • 怎么创建css样式表,怎样创建可反复使用的外部CSS样式表?[通俗易懂]

    怎么创建css样式表,怎样创建可反复使用的外部CSS样式表?[通俗易懂]创建可反复使用的外部CSS样式表用DreamWeaver在某网页中创建了一种CSS样式后,如果你要在另外的网页中应用该样式,你不必从新创建该CSS样式,只要你创建了外部CSS样式表文件(externalCSSstylesheet),你便可以在今后任意调用该样式表文件中的样式。为了便于管理,先在站点所在文件夹中,新建一个文件夹,取名为CSS,专门用于放置外部样式表文件(其扩展名为css)。1、在Do…

    2022年7月14日
    14
  • Vbs调用MsAgent组件,很有趣

    Vbs调用MsAgent组件,很有趣MicrosoftAgent是微软公司发布的一项代理软件开发技术,我们知道,在Office帮助系统中有一种叫作Office助手的代理软件,但其只允许Office各个组件调用,Agent动画人物可由任何Windows程序调用;Agent支持文字气球和输入提示条,在输出语音的同时把文字输出至一个卡通式文字气球中。如果电脑系统中安装有Agent语音识别引擎,当用户可以通过声卡、麦克风与用户交谈…

    2022年6月17日
    23
  • synchronousqueue场景_java中SynchronousQueue的核心方法

    synchronousqueue场景_java中SynchronousQueue的核心方法我们之前提过SynchronousQueue入队和出队的两种方法,其实它们都依托transfer方法得以实现。相比较而言,transfer可以同步进行入队和出队的操作,是SynchronousQueue中最重要的核心方法。下面我们就transfer概念、使用场景,以及在代码中增减元素的实例带来全面介绍。1.transfer概念进行匹配交换数据,SynchronousQueue内部使用Transfe…

    2022年6月22日
    48
  • SpringMVC 中ModelAndView用法

    SpringMVC 中ModelAndView用法ModelAndView作用1.返回到指定的页面ModelAndView构造方法可以指定返回的页面名称   例:returnnewModelAndView("redirect:/m07.jsp");通过setViewName()方法跳转到指定的页面   例:mav.setViewName("hello"); 2.返回参数到指定页面的request作用于中使…

    2022年7月18日
    52

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号