`
zsybupt
  • 浏览: 41463 次
  • 性别: Icon_minigender_1
社区版块
存档分类
最新评论

boj 268

    博客分类:
  • oj
 
阅读更多

Description
A brand new sapper robot is able to neutralize mines in a rectangular region having integer height and width (N and M respectively). Before the robot begins its work it is placed near the top leftmost cell of the rectangle heading right. Then the robot starts moving and neutralizing mines making a clockwise spiral way (see picture). The spiral twists towards the inside of the region, covering all the cells. The region is considered safe when all the cells are visited and checked by the robot.
Your task is to determine the number of the turns the robot has to make during its work.



Input
There are no more than 10000 cases, end by EOF.
For each case, there is one line contains two integers in the following order: N, M (1 ≤ N, M ≤ 2^31 − 1).


Output
For each case, output a single integer value in a line, the number of the turns.

Sample Input

3 5
3 1


Sample Output

4
1
水题 找规律即可
代码:
#include<iostream>
using namespace std;
int main()
{
	long long m,n;
	while(~scanf("%lld %lld",&n,&m))
	{
		long long ans = 0;
		if(m<=n-1) ans+=(m-1)*2+1;
		else ans+=2*(n-1);
		printf("%lld\n",ans);
	}
}
 
分享到:
评论

相关推荐

    BOJ题目1023. Ancient Keyboard 源代码

    BOJ的题目1023. Ancient Keyboard解法 源代码

    boj 0809复试模拟题答案

    boj 上08 09 年复试模拟题的答案

    JAVA_BOJ

    JAVA_BOJ

    boj:算法

    boj:算法

    Algorithm-BOJ.zip

    Algorithm-BOJ.zip,BekJon在线法官(Java,Kotlin,SWIFT)和PS路线图,算法是为计算机程序高效、彻底地完成任务而创建的一组详细的准则。

    BOJ

    BOJ

    Algorithm-BOJ-PSJ.zip

    Algorithm-BOJ-PSJ.zip,Baykon在线判断JAVA问题解决方法(第二章),算法是为计算机程序高效、彻底地完成任务而创建的一组详细的准则。

    Algorithm-BOJ-AutoCommit.zip

    Algorithm-BOJ-AutoCommit.zip,当您解决baekjoon online judge的问题时,它会自动提交并推送到远程存储库。,算法是为计算机程序高效、彻底地完成任务而创建的一组详细的准则。

    Algorithm-boj-auto-submit.zip

    Algorithm-boj-auto-submit.zip,日本央行cli提交脚本,算法是为计算机程序高效、彻底地完成任务而创建的一组详细的准则。

    Python库 | boj-0.0.1.tar.gz

    资源分类:Python库 所属语言:Python 资源全名:boj-0.0.1.tar.gz 资源来源:官方 安装方法:https://lanzao.blog.csdn.net/article/details/101784059

    Boj Coloring Book-crx插件

    通过这本图画书展示您的创造力,其中包括Boj和朋友。 一本有趣的,全数字化且可重复使用的着色书,可用于 通过这本图画书展示您的创造力,其中包括Boj和朋友。 一本有趣的全数字可重复使用的图画书,专为孩子,父母...

    boj.kr:解决boj.kr的问题

    解决问题 Boj.kr

    BOJ:日本央行

    BOJ:日本央行

    boj:算法求解

    boj:算法求解

Global site tag (gtag.js) - Google Analytics