Codeforces Round #541 (Div. 2) A.Sea Battle
链接:https://codeforces.com/contest/1131/problem/A
题意:
给两个矩形,一个再上一个在下,求两个矩形合并的周围一圈的面积。
思路:
因为存在下面矩形宽度大于上面,所以先求下面矩形周围面积,再求上方矩形最下一行除外的面积。
代码:
#include <bits/stdc++.h> using namespace std; typedef long long LL; int main()
{
int w1, h1, w2, h2;
cin >> w1 >> h1 >> w2 >> h2;
cout << (w1 + 2) * (h1 + 2) - w1 * h1 - w2 + h2 * (w2 + 2) - (h2 - 1) * w2 << endl; return 0;
}
Codeforces Round #541 (Div. 2) A.Sea Battle的更多相关文章
- Codeforces Round #380 (Div. 2)/729D Sea Battle 思维题
Galya is playing one-dimensional Sea Battle on a 1 × n grid. In this game a ships are placed on the ...
- 构造 Codeforces Round #302 (Div. 2) B Sea and Islands
题目传送门 /* 题意:在n^n的海洋里是否有k块陆地 构造算法:按奇偶性来判断,k小于等于所有点数的一半,交叉输出L/S 输出完k个L后,之后全部输出S:) 5 10 的例子可以是这样的: LSLS ...
- Codeforces Round #541 (Div. 2)
Codeforces Round #541 (Div. 2) http://codeforces.com/contest/1131 A #include<bits/stdc++.h> us ...
- Codeforces 1131 A. Sea Battle-暴力 (Codeforces Round #541 (Div. 2))
A. Sea Battle time limit per test 1 second memory limit per test 256 megabytes input standard input ...
- Codeforces Round #541 (Div. 2) (A~F)
目录 Codeforces 1131 A.Sea Battle B.Draw! C.Birthday D.Gourmet choice(拓扑排序) E.String Multiplication(思路 ...
- Codeforces Round #Pi (Div. 2) D. One-Dimensional Battle Ships set乱搞
D. One-Dimensional Battle ShipsTime Limit: 2 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/con ...
- Codeforces Round #Pi (Div. 2) D. One-Dimensional Battle Ships set区间分解
D. One-Dimensional Battle ShipsTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/co ...
- Codeforces Round #302 (Div. 2) B. Sea and Islands 构造
B. Sea and Islands Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/544/p ...
- Codeforces Round #541 (Div. 2)题解
不知道该更些什么 随便写点东西吧 https://codeforces.com/contest/1131 ABC 太热了不写了 D 把相等的用并查集缩在一起 如果$ x<y$则从$ x$往$y$ ...
随机推荐
- zk使用通知移除节点
前面:https://www.cnblogs.com/toov5/p/9899238.html 服务发生宕机 咋办? 发个事件通知,告知大家哟, 会有通知事件哦 看项目: 服务端: package c ...
- html5--5-9 绘制扇形
html5--5-9 绘制扇形 学习要点 综合运用已经学过的知识绘制一个扇形 矩形的绘制方法 rect(x,y,w,h)创建一个矩形 strokeRect(x,y,w,hx,y,w,h) 绘制矩形(无 ...
- Facebook图片存储系统Haystack——存小文件,本质上是将多个小文件合并为一个大文件来降低io次数,meta data里存偏移量
转自:http://yanyiwu.com/work/2015/01/04/Haystack.html 一篇14页的论文Facebook-Haystack, 看完之后我的印象里就四句话: 因为[传统文 ...
- 什么是HTTP协议?
HTTP协议(超文本传输协议)位于TCP/IP协议栈的应用层.传输层采用面向连接的TCP HTTP请求详细过程
- Constructing Roads In JGShining's Kingdom
点击打开题目链接 本题目是考察 最长递增子序列的 有n^2 n(logn) n^2 会超时的 下面两个方法的代码 思路 可以百度LIS LCS dp里面存子序列 n(logn) ...
- 【转】使用vue-cli搭建项目
vue-cli 是一个官方发布 vue.js 项目脚手架,使用 vue-cli 可以快速创建 vue 项目,GitHub地址是:https://github.com/vuejs/vue-cli 一. ...
- JavaScript 日期处理类库 moment
可以自定义自己需要的时间格式,中文文档如下: http://momentjs.cn/ http://momentjs.cn/docs/
- js搜索相同类型的控件全选、取值(Checkbox)
function selectAll(obj) { if (obj.checked) { $("input[type='checkbox']").each(function () ...
- ping测试网络
https://jingyan.baidu.com/article/ac6a9a5e109d5f2b653eacbc.html 百度百科:https://baike.baidu.com/item/pi ...
- Linux命令行设置环境变量
参考 Linux命令行--使用linux环境变量 Linux命令行—使用Linux环境变量