479A - Expression

本文介绍了一个关于数学表达式的编程问题:如何通过合理地插入加号和乘号运算符及括号来使得由三个整数构成的表达式值最大化。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

A. 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= gets.to_i,gets.to_i,gets.to_i
puts [a + b + c, (a + b) * c, a + b * c, a * b + c, a * (b + c), a * b * c].max
(fealpy_env) py@py:~$ pip3 install PyMUMPS Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple Collecting PyMUMPS Downloading https://pypi.tuna.tsinghua.edu.cn/packages/8d/36/75ff7ce99ff1f65132af5a310c10eeb6f80537ad352570a39f1c1eb239b7/pymumps-0.3.3.tar.gz (8.2 kB) Installing build dependencies ... done Getting requirements to build wheel ... done Preparing metadata (pyproject.toml) ... done Collecting mpi4py (from PyMUMPS) Downloading https://pypi.tuna.tsinghua.edu.cn/packages/85/22/4d9a9290010d4b95d3991ac383b2b7763ecebccafe366cb64f4abf479c41/mpi4py-4.1.0-cp310-cp310-manylinux1_x86_64.manylinux_2_5_x86_64.whl (1.4 MB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.4/1.4 MB 10.7 MB/s eta 0:00:00 Building wheels for collected packages: PyMUMPS Building wheel for PyMUMPS (pyproject.toml) ... error error: subprocess-exited-with-error × Building wheel for PyMUMPS (pyproject.toml) did not run successfully. │ exit code: 1 ╰─> [40 lines of output] /tmp/pip-build-env-d5nmvfu3/overlay/lib/python3.10/site-packages/setuptools/dist.py:759: SetuptoolsDeprecationWarning: License classifiers are deprecated. !! ******************************************************************************** Please consider removing the following classifiers in favor of a SPDX license expression: License :: OSI Approved :: BSD License See https://packaging.python.org/en/latest/guides/writing-pyproject-toml/#license for details. ******************************************************************************** !! self._finalize_license_expression() running bdist_wheel running build running build_py creating build/lib.linux-x86_64-cpython-310/mumps copying mumps/__init__.py -> build/lib.linux-x86_64-cpython-310/mumps running build_ext warning: mumps/_dmumps.pyx:62:23: Non-trivial type declarators in shared declaration (e.g. mix of pointers and values). Each pointer declaration should be on its own line. warning: mumps/_dmumps.pyx:62:29: Non-trivial type declarators in shared declaration (e.g. mix of pointers and values). Each pointer declaration should be on its own line. warning: mumps/_dmumps.pyx:62:38: Non-trivial type declarators in shared declaration (e.g. mix of pointers and values). Each pointer declaration should be on its own line. warning: mumps/_dmumps.pyx:62:51: Non-trivial type declarators in shared declaration (e.g. mix of pointers and values). Each pointer declaration should be on its own line. warning: mumps/_dmumps.pyx:63:23: Non-trivial type declarators in shared declaration (e.g. mix of pointers and values). Each pointer declaration should be on its own line. warning: mumps/_dmumps.pyx:63:37: Non-trivial type declarators in shared declaration (e.g. mix of pointers and values). Each pointer declaration should be on its own line. warning: mumps/_dmumps.pyx:63:48: Non-trivial type declarators in shared declaration (e.g. mix of pointers and values). Each pointer declaration should be on its own line. warning: mumps/_dmumps.pyx:67:27: Non-trivial type declarators in shared declaration (e.g. mix of pointers and values). Each pointer declaration should be on its own line. warning: mumps/_dmumps.pyx:67:37: Non-trivial type declarators in shared declaration (e.g. mix of pointers and values). Each pointer declaration should be on its own line. warning: mumps/_dmumps.pyx:68:28: Non-trivial type declarators in shared declaration (e.g. mix of pointers and values). Each pointer declaration should be on its own line. warning: mumps/_dmumps.pyx:68:40: Non-trivial type declarators in shared declaration (e.g. mix of pointers and values). Each pointer declaration should be on its own line. Compiling mumps/_dmumps.pyx because it changed. [1/1] Cythonizing mumps/_dmumps.pyx building 'mumps._dmumps' extension creating build/temp.linux-x86_64-cpython-310/mumps x86_64-linux-gnu-gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -fPIC -I/home/py/fealpy_env/include -I/usr/include/python3.10 -c mumps/_dmumps.c -o build/temp.linux-x86_64-cpython-310/mumps/_dmumps.o mumps/_dmumps.c:1136:10: fatal error: dmumps_c.h: No such file or directory 1136 | #include "dmumps_c.h" | ^~~~~~~~~~~~ compilation terminated. error: command '/usr/bin/x86_64-linux-gnu-gcc' failed with exit code 1 [end of output] note: This error originates from a subprocess, and is likely not a problem with pip. ERROR: Failed building wheel for PyMUMPS Failed to build PyMUMPS ERROR: Failed to build installable wheels for some pyproject.toml based projects (PyMUMPS) (fealpy_env) py@py:~$
最新发布
07-05
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值