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


相关推荐

  • @ResponseBody注解的作用

    @ResponseBody注解的作用 1、  @ResponseBody注解的作用是将controller的方法返回的对象通过适当的转换器转换为指定的格式之后,写入到response对象的body区(响应体中),通常用来返回JSON数据或者是XML。  数据,需要注意的呢,在使用此注解之后不会再走视图处理器,而是直接将数据写入到输入流中,它的效果等同于通过response对象输出指定格式的数据。    这里…

    2022年5月28日
    40
  • 通过CLR API实现C++调用C#代码交互

    通过CLR API实现C++调用C#代码交互

    2021年9月2日
    63
  • Linux下安装Redis

    Linux下安装Redis官网下载链接:https://redis.io/download1、选择Stable(5.0)下的Download5.0.0链接进行下载(stable是稳定版本,默认下载的是linux版本)2、下载完成之后,打开WinSCP,把我们下载好的Redis压缩包,上传到Linux的/mnt/文件目录下3、使用putty连接到我们的Li…

    2022年4月30日
    50
  • 数据库与数据仓库区别

    数据库与数据仓库区别在具体学习数据仓库之前先看一下数据中心的整体构架以及数据流向 DB 是现有的数据来源 可以为 mysql SQLserver 文件日志等 为数据仓库提供数据来源的一般存在于现有的业务系统之中 ETL 是 Extract Transform Load 的缩写 用来描述将数据从来源迁移到目标的几个过程 Extract 数据抽取 也就是把数据从数据源读出来 Transform 数据转换 把原始数据转换成期望的格式和维度 如果用在数据仓库的场景下 Transform 也包含数据清洗 清

    2025年12月13日
    5
  • idea2021.10.3激活码【2021免费激活】

    (idea2021.10.3激活码)好多小伙伴总是说激活码老是失效,太麻烦,关注/收藏全栈君太难教程,2021永久激活的方法等着你。IntelliJ2021最新激活注册码,破解教程可免费永久激活,亲测有效,下面是详细链接哦~https://javaforall.net/100143.html0YQJ1128OW-eyJsaWNlbnNlSW…

    2022年3月28日
    48
  • java buttongroup方框_Swing之ButtonGroup用法实例 | 学步园

    java buttongroup方框_Swing之ButtonGroup用法实例 | 学步园1就是起作用范围的,不是组件,不能被容器添加,目的让其中一个起作用,例如radiobuttonpackagecom.szsm.swing.framepanel;importjava.awt.FlowLayout;importjavax.swing.ButtonGroup;importjavax.swing.JRadioButton;importcom.szsm.swing.parent…

    2025年7月27日
    3

发表回复

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

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