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


相关推荐

  • FVWM_fw一流是什么意思

    FVWM_fw一流是什么意思国庆期间,把自己的FVWM好好整理了一下,现在我的桌面看上去是这个样子滴(点击可放大):我的.fvwm2rc可以下载。我的部分FVWM笔记:***   如何使用托盘      $sudoapt-getinstalltrayer      $trayer–widthtypepixel–width128–height32–edgebottom&***  

    2022年10月4日
    0
  • 虚拟机ifconfig或ip addr不显示ip地址「建议收藏」

    虚拟机ifconfig或ip addr不显示ip地址「建议收藏」虚拟机ifconfig或ipaddr不显示ip地址报错图片:一直查不到ip地址,有重新启动很多次解决方法(1)命令查看配置文件:vi/etc/sysconfig/network-scripts/ifcfg-ens33ens33注意看这个修改的文件后缀把ONBOOT的状态no改为yes然后重启,应该就没问题了。(2):还有一种可能是因为虚拟网卡没有正常连接,解决方法是开启虚拟网卡的服务:打开任务管理器,选择服务标签,为了保险,开启所有的和vmware有关的服务检

    2022年7月27日
    1
  • why在重写equals时还必须重写hashcode方法

    why在重写equals时还必须重写hashcode方法

    2022年2月22日
    36
  • stm32f103+FFT+OLED的音乐频谱制作(只需三步即可)「建议收藏」

    stm32f103+FFT+OLED的音乐频谱制作(只需三步即可)「建议收藏」效果演示:https://www.bilibili.com/video/av29366031/制作过程:1.准备材料:stm32f103核心板1块OLED12864显示屏1块(SPI接口)声音检测传感器1块(咪头+放大电路可以网上买现成的模块,也可根据后文提供的原理图自己做)2.硬件连接:(1)OLED连接:OLED_SCLK————PB7OL…

    2022年10月21日
    0
  • 合成控制法 (Synthetic Control Method) 及 Stata实现[通俗易懂]

    合成控制法 (Synthetic Control Method) 及 Stata实现[通俗易懂]作者:何庆红(北京大学中国卫生经济研究中心)连享会:(知乎|简书|码云|CSDN) 2019暑期“实证研究方法与经典论文”专题班-连玉君-江艇主讲 本推文介绍合成控制方法及其Stata的实现命令。合成控制方法(SyntheticControlMethod)由AbadieandGardeazabal(2003)提出。目前,该方法已被广泛使用。1.背景介绍…

    2022年4月27日
    51
  • aria2最新tracker服务器,【无灯+Hiboy】padavan下自动更新aria2的BT tracker 服务器列表…「建议收藏」

    aria2最新tracker服务器,【无灯+Hiboy】padavan下自动更新aria2的BT tracker 服务器列表…「建议收藏」本帖最后由Wildest_Dreams于2018-12-2120:00编辑首先,在`/etc/storage`目录创建`trackers_list_aria2.sh`在其它目录重启就会丢失脚本!在其它目录重启就会丢失脚本!在其它目录重启就会丢失脚本!荒野无灯版请输入以下代码:#!/bin/bash/usr/bin/aria.shstoplist=`wget-qO-https://r…

    2022年10月1日
    0

发表回复

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

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