A1151 | [COCI-2008_2009-contest2]#2 KORNISLAV
来源COCI
时间限制1s
内存限制128MB
通过 / 提交0/0
题目描述
Kornislav the turtle never has anything interesting to do. Since he's going to live for three hundred years, he keeps trying to find way to kill time. This weekend he started playing "enclose the largest rectangle".
To start with, Kornislav needs four positive integers. He tries to enclose a rectangle by moving in one direction, then turning 90 degrees, then walking in the new direction etc. Kornislav makes a total of three 90-degree turns and walks four segments.
When walking in some direction, the number of steps he takes must be equal to one of the four chosen integers and each integer must be used exactly once. Depending on the order in which Kornislav uses the integers, his walk will make various shapes, some of which don't contain enclosed rectangles.
Write a program that calculates the largest rectangle the turtle can enclose with its walk.
To start with, Kornislav needs four positive integers. He tries to enclose a rectangle by moving in one direction, then turning 90 degrees, then walking in the new direction etc. Kornislav makes a total of three 90-degree turns and walks four segments.
When walking in some direction, the number of steps he takes must be equal to one of the four chosen integers and each integer must be used exactly once. Depending on the order in which Kornislav uses the integers, his walk will make various shapes, some of which don't contain enclosed rectangles.
Write a program that calculates the largest rectangle the turtle can enclose with its walk.
输入格式
The first line contains four positive integers A, B, C and D (0 < A, B, C, D < 100), the four chosen integers.
输出格式
Output the largest area.
输入输出样例
输入 #1
1 2 3 4
输出 #1
3
输入 #2
4 4 3 4
输出 #2
12
In the first example, one possible way for Kornislav to enclose a rectangle of area 3:
• Make 4 steps forward;
• Turn right;
• Make 1 step forward;
• Turn right;
• Make 3 steps forward;
• Turn right;
• Make 2 steps forward.
• Make 4 steps forward;
• Turn right;
• Make 1 step forward;
• Turn right;
• Make 3 steps forward;
• Turn right;
• Make 2 steps forward.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted