Codeforces 1131 A. Sea Battle-暴力 (Codeforces Round #541 (Div. 2))
1 second
256 megabytes
standard input
standard output
In order to make the "Sea Battle" game more interesting, Boris decided to add a new ship type to it. The ship consists of two rectangles. The first rectangle has a width of w1w1 and a height of h1h1, while the second rectangle has a width of w2w2 and a height of h2h2, where w1≥w2w1≥w2. In this game, exactly one ship is used, made up of two rectangles. There are no other ships on the field.
The rectangles are placed on field in the following way:
- the second rectangle is on top the first rectangle;
- they are aligned to the left, i.e. their left sides are on the same line;
- the rectangles are adjacent to each other without a gap.
See the pictures in the notes: the first rectangle is colored red, the second rectangle is colored blue.
Formally, let's introduce a coordinate system. Then, the leftmost bottom cell of the first rectangle has coordinates (1,1)(1,1), the rightmost top cell of the first rectangle has coordinates (w1,h1)(w1,h1), the leftmost bottom cell of the second rectangle has coordinates (1,h1+1)(1,h1+1) and the rightmost top cell of the second rectangle has coordinates (w2,h1+h2)(w2,h1+h2).
After the ship is completely destroyed, all cells neighboring by side or a corner with the ship are marked. Of course, only cells, which don't belong to the ship are marked. On the pictures in the notes such cells are colored green.
Find out how many cells should be marked after the ship is destroyed. The field of the game is infinite in any direction.
Four lines contain integers w1,h1,w2w1,h1,w2 and h2h2 (1≤w1,h1,w2,h2≤1081≤w1,h1,w2,h2≤108, w1≥w2w1≥w2) — the width of the first rectangle, the height of the first rectangle, the width of the second rectangle and the height of the second rectangle. You can't rotate the rectangles.
Print exactly one integer — the number of cells, which should be marked after the ship is destroyed.
2 1 2 1
12
2 2 1 2
16
In the first example the field looks as follows (the first rectangle is red, the second rectangle is blue, green shows the marked squares):

In the second example the field looks as:

题意就是算包围两个矩形的小方块的个数。
代码:
//A
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e5+; int main()
{
int a,b,c,d;
cin>>a>>b>>c>>d;
ll ans=+max(a,c)*+*(b+d);
cout<<ans<<endl;
}
Codeforces 1131 A. Sea Battle-暴力 (Codeforces Round #541 (Div. 2))的更多相关文章
- Codeforces Round #541 (Div. 2) (A~F)
		目录 Codeforces 1131 A.Sea Battle B.Draw! C.Birthday D.Gourmet choice(拓扑排序) E.String Multiplication(思路 ... 
- Codeforces Round #541 (Div. 2)
		Codeforces Round #541 (Div. 2) http://codeforces.com/contest/1131 A #include<bits/stdc++.h> us ... 
- 【Codeforces 738D】Sea Battle(贪心)
		http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n g ... 
- codeforces_Codeforces Round #541 (Div. 2)_abc
		A. Sea Battle time limit per test 1 second memory limit per test 256 megabytes input standard input ... 
- Codeforces Round #541 (Div. 2) A.Sea Battle
		链接:https://codeforces.com/contest/1131/problem/A 题意: 给两个矩形,一个再上一个在下,求两个矩形合并的周围一圈的面积. 思路: 因为存在下面矩形宽度大 ... 
- Codeforces 1131 B. Draw!-暴力 (Codeforces Round #541 (Div. 2))
		B. Draw! time limit per test 2 seconds memory limit per test 256 megabytes input standard input outp ... 
- Codeforces 1131 F. Asya And Kittens-双向链表(模拟或者STL list)+并查集(或者STL list的splice()函数)-对不起,我太菜了。。。 (Codeforces Round #541 (Div. 2))
		F. Asya And Kittens time limit per test 2 seconds memory limit per test 256 megabytes input standard ... 
- Codeforces 1131 C. Birthday-暴力 (Codeforces Round #541 (Div. 2))
		C. Birthday time limit per test 1 second memory limit per test 256 megabytes input standard input ou ... 
- Codeforces Round #541 (Div. 2)题解
		不知道该更些什么 随便写点东西吧 https://codeforces.com/contest/1131 ABC 太热了不写了 D 把相等的用并查集缩在一起 如果$ x<y$则从$ x$往$y$ ... 
随机推荐
- 使用jquery.qrcode生成二维码及常见问题解决方案
			转载文章 使用jquery.qrcode生成二维码及常见问题解决方案 一.jquery.qrcode.js介 jquery.qrcode.js 是一个纯浏览器 生成 QRcode 的 jQuery ... 
- ZOJ 3556 How Many Sets I
			How Many Sets I Time Limit: 2 Seconds Memory Limit: 65536 KB Give a set S, |S| = n, then how ma ... 
- dijkstra spfa prim kruskal 总结
			最短路和最小生成树应该是很早学的,大家一般都打得烂熟,总结一下几个问题 一 dijkstra O((V+E)lgV) //V节点数 E边数 dijkstra不能用来求最长路,因为此时局部最优解已经 ... 
- 【BZOJ】2705: [SDOI2012]Longge的问题
			[题意]给定n,求∑gcd(i,n),(1<=i<=n),n<=2^32 [算法]数论(欧拉函数,gcd) [题解]批量求gcd的题目常常可以反过来枚举gcd的值. 记f(g)为gc ... 
- ios资源加载策略
			做了好几个月的ios,大框架都是别人搭好的,自己只是实现逻辑,很是失落.慢慢开始整理学习一些概念类的东西吧,希望自己能提高点. cocos2d-x从cocos2d-2.0-x-2.0.2开始,考虑到自 ... 
- java解析XML之DOM解析和SAX解析(包含CDATA的问题)
			Dom解析功能强大,可增删改查,操作时会将XML文档读到内存,因此适用于小文档: SAX解析是从头到尾逐行逐个元素解析,修改较为不便,但适用于只读的大文档:SAX采用事件驱动的方式解析XML.如同在电 ... 
- 修改ES使用root用户运行
			默认ES不允许使用root用户运行,如果使用root会报如下图的错误: ,通常建议创建elsearch用户并使用该用户运行ES.但如果必须使用root用户时,按如下设置即可: 1.启动是使用如下命令 ... 
- wce.exe getpass.exe 读取密码
			http://www.ampliasecurity.com/research/wce_v1_4beta_x32.zip http://www.ampliasecurity.com/research/w ... 
- 看jquery3.3.1学js类型判断的技巧
			需要预习:call , typeof, js数据类型 1. isFunction中typeof的不靠谱 源码: var isFunction = function isFunction( obj ) ... 
- VPS性能测试(1):CPU物理个数、内核、超线程、多核心
			1.登录VPS界面,执行:cat /proc/cpuinfo,就会显示出VPS主机的CPU详细参数,如内核.频率.型号等等 2.主要参数physical_id表示物理CPU个数,cpu cores是内 ... 
