time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

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.

Input

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.

Output

Print exactly one integer — the number of cells, which should be marked after the ship is destroyed.

Examples
input

Copy
2 1 2 1
output

Copy
12
input

Copy
2 2 1 2
output

Copy
16
Note

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))的更多相关文章

  1. Codeforces Round #541 (Div. 2) (A~F)

    目录 Codeforces 1131 A.Sea Battle B.Draw! C.Birthday D.Gourmet choice(拓扑排序) E.String Multiplication(思路 ...

  2. Codeforces Round #541 (Div. 2)

    Codeforces Round #541 (Div. 2) http://codeforces.com/contest/1131 A #include<bits/stdc++.h> us ...

  3. 【Codeforces 738D】Sea Battle(贪心)

    http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n g ...

  4. 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 ...

  5. Codeforces Round #541 (Div. 2) A.Sea Battle

    链接:https://codeforces.com/contest/1131/problem/A 题意: 给两个矩形,一个再上一个在下,求两个矩形合并的周围一圈的面积. 思路: 因为存在下面矩形宽度大 ...

  6. 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 ...

  7. 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 ...

  8. 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 ...

  9. Codeforces Round #541 (Div. 2)题解

    不知道该更些什么 随便写点东西吧 https://codeforces.com/contest/1131 ABC 太热了不写了 D 把相等的用并查集缩在一起 如果$ x<y$则从$ x$往$y$ ...

随机推荐

  1. zoj 1729 Hidden Password

    Hidden Passwordhttp://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=729 Time Limit: 2 Seconds ...

  2. Merge Query

    1. Oracle: "MERGE into MHGROUP.proj_access m using dual on " + "(PRJ_ID = '" + W ...

  3. 在此位置打开CMD

    Windows Registry Editor Version 5.00 [HKEY_CLASSES_ROOT\folder\shell\cmd]@="在此位置打开CMD"[HKE ...

  4. 【NOIP】提高组2015 运输计划

    [题意]n个点的树,m条链,求将一条边的权值置为0使得最大链长最小. [算法]二分+树上差分 [题解] 最大值最小化问题,先考虑二分最大链长. 对所有链长>mid的链整体+1(树上差分). 然后 ...

  5. js监听浏览器后退事件

    $(document).ready(function(e) {             var counter = 0;            if (window.history && ...

  6. bzoj 1046 LIS

    假设我们知道以每个点开始到最后的最长上升序列,设为w[i],这样首先我们在w值中取max,如果询问的值比max大,这样显然就是无解,如果小的话,我们需要求出来字典序最小的方案. 那么对于所有i,我们肯 ...

  7. BigDecimal的用法详解

    BigDecimal 由任意精度的整数非标度值 和32 位的整数标度 (scale) 组成.如果为零或正数,则标度是小数点后的位数.如果为负数,则将该数的非标度值乘以 10 的负scale 次幂. f ...

  8. linux 下 /bin /sbin 的区别 -- (转)

    /bin,/sbin,/usr/bin,/usr/sbin区别 /  : this is root directory                root 用户根目录 /bin : command ...

  9. Python eval 函数说明

    eval(str [,globals [,locals ]]) -- 函数将字符串str当成有效Python表达式来求值,并返回计算结果. 例 :  eval('3+4')         ==> ...

  10. C题 hdu 1408 盐水的故事

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1408 盐水的故事 Time Limit: 2000/1000 MS (Java/Others)     ...