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)
上一篇 2022年1月11日 上午11:00
下一篇 2022年1月11日 下午1:00


相关推荐

  • centos 6.5 p2v virt-p2v过程详解之一

    centos 6.5 p2v virt-p2v过程详解之一在此就不写关于那些概念和定义了,直接就写出过程一、安装kvmKVM需要有CPU的支持(Intelvmx或AMDsvm),在安装KVM之前检查一下CPU是否提供了虚拟技术的支持:#egrep’^flags.*(vmx|svm)’/proc/cpuinfo有显示,有显示则说明处理器具有VT功能,在主板BIOS中开启CPU的VirtualTechnoleg

    2022年7月26日
    11
  • 三千多元就有32GB显存?A770双卡部署DeepSeek-R1 32B

    三千多元就有32GB显存?A770双卡部署DeepSeek-R1 32B

    2026年3月16日
    3
  • 什么是产品的roadmap

    什么是产品的roadmap让团队成员清楚知道产品要往哪个方向走 怎么走 在什么时间要做什么事情 road 即路在何方 map 即身处何处 如何到达

    2026年3月18日
    2
  • 《欧美剧集观看最佳索引》【2006-9-24更新】

    《欧美剧集观看最佳索引》【2006-9-24更新】 allyesno:我在上两个月说要做一个美剧的网站由于最近公司的事情一直很繁忙我没有时间去做自己都积累了一大堆美剧日剧恐怖片没看两个电脑的硬盘都塞的满满的呵呵真是天长地久有时尽,此恨绵绵无绝期。哈哈~“我现在正在构思是不是把美剧网站列入公司的发展计划的一部分来做这样我的兴趣和工作就能结合在一起而且也能得到更大的硬件平台以及人力资源的支持一切都在

    2022年8月10日
    9
  • gradle的配置_安卓gradle安装和使用配置

    gradle的配置_安卓gradle安装和使用配置初识GradleGradle是一个基于ApacheAnt和ApacheMaven概念的项目自动化建构工具。它使用一种基于Groovy的特定领域语言来声明项目设置,而不是传统的XML。当前其支持的语言限于Java、Groovy和Scala,计划未来将支持更多的语言。怎么看上面都是一段很官方的解释,对于入门的人来说简直是一个噩梦般的解释(包括以前的我)。那下面我就用通俗一点语言说说我的理解…

    2025年6月23日
    6
  • C语言小项目——计时器(倒计时+报警提示)「建议收藏」

    大家对计时器应该不陌生,我们在制定一个计划时,经常喜欢设置一个倒计时来规定完成时限,等计时结束,它还会报警提示,今天,我就用C语言编写一个简易的倒计时计时器。

    2022年4月7日
    58

发表回复

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

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