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)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • 解决报错(Navigation cancelled from “/roleList“ to “/userlist“ with a new navigation.)[通俗易懂]

    解决报错(Navigation cancelled from “/roleList“ to “/userlist“ with a new navigation.)[通俗易懂]写项目的时候,报了一个错,现在总结出来,希望可以帮助到你们。这个报错的原因:使用新导航取消了从“/roleList”到“/userlist”的导航。解决的方法:关于VueRouter报错路由

    2022年7月1日
    155
  • Eclipse自动补全功能设置

    Eclipse自动补全功能设置如何设置Eclipse自动补全方法一:按照步骤设置第一步:点击Eclipse导航栏的Window按钮第二步:在Eclipse导航栏的window中找到preferences第三部:进入preferences中找到java→Editor→ContentAssit,在红箭头所指的方框内输入26个英文字母和一些符号“‘<>按照这些操作来进行,您就可以让Eclipse自动补全方法二:使用快捷键Alt+/…

    2022年6月28日
    34
  • python querystring encode_querystring

    python querystring encode_querystringquerystring(查询字符串)querystring模块提供用于解析和格式化URL查询字符串的实用工具。可以使用以下方式访问它:constquerystring=require(‘querystring’);querystring.decode()新增于:v0.1.99querystring.decode()函数是querystring.parse()的别名。querys…

    2025年8月25日
    3
  • Java中HashMap底层实现原理(JDK1.8)源码分析「建议收藏」

    这几天学习了HashMap的底层实现,但是发现好几个版本的,代码不一,而且看了Android包的HashMap和JDK中的HashMap的也不是一样,原来他们没有指定JDK版本,很多文章都是旧版本JDK1.6.JDK1.7的。现在我来分析一哈最新的JDK1.8的HashMap及性能优化。在JDK1.6,JDK1.7中,HashMap采用位桶+链表实现,即使用链表处理冲突,同一hash值

    2022年4月10日
    46
  • java最新漏洞_JavaMelody XXE漏洞(CVE-2018-15531)分析

    java最新漏洞_JavaMelody XXE漏洞(CVE-2018-15531)分析0x01背景JavaMelody是一款在生产和QA环境中对JAVA应用以及应用服务器(Tomcat、Jboss、Weblogic)进行监控的工具,可以通过图表给出监控数据,方便研发运维等找出响应瓶颈、优化响应等。近日发布了1.74.0版本,修复了一个XXE漏洞,漏洞编号CVE-2018-15531。攻击者利用漏洞,可以读取JavaMelody服务器上的敏感信息。0x02漏洞分析漏洞修复的com…

    2022年7月7日
    71
  • reading recovery_the common reader

    reading recovery_the common readerBookKeeperAutoRecovery背景版本:BookKeeper版本为4.12.0(Pulsar2.7.0的内置版本)Recovery主要针对的场景是:当集群中有部分bookie节点因异常原因宕机,此时我们恢复该节点上存储的数据。BookKeeper提供了两种数据恢复方式,一种是手动恢复(Manualrecovery),一种是自动恢复(AutoRecovery)。ManualRecovery如果集群中未开启AutoRecovery的功能,则用户可用手动恢复。手动恢复

    2025年8月4日
    4

发表回复

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

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