URAL 1224. Spiral (规律)
1224. Spiral
Memory limit: 64 MB
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.
Input
N, M (1 ≤ N, M ≤ 231 − 1).
Output
Sample
| input | output |
|---|---|
3 5 |
4 |
Problem Source: 2002-2003 ACM Central Region of Russia Quarterfinal Programming Contest, Rybinsk, October 2002
解析:找规律。一定要注意n和m的大小关系,由于出发地点是固定的。
AC代码:
#include <bits/stdc++.h>
using namespace std; int main(){
long long n, m;
while(~scanf("%lld%lld", &n, &m)){
long long ans;
if(n <= m) ans = 2 * (n - 1);
else ans = 2 * m - 1;
printf("%lld\n", ans);
}
return 0;
}
URAL 1224. Spiral (规律)的更多相关文章
- 【规律】Growing Rectangular Spiral
Growing Rectangular Spiral 题目描述 A growing rectangular spiral is a connected sequence of straightline ...
- URAL 2070 Interesting Numbers (找规律)
题意:在[L, R]之间求:x是个素数,因子个数是素数,同时满足两个条件,或者同时不满足两个条件的数的个数. 析:很明显所有的素数,因数都是2,是素数,所以我们只要算不是素数但因子是素数的数目就好,然 ...
- URAL 1780 G - Gray Code 找规律
G - Gray CodeTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contest/view ...
- URAL 1180. Stone Game (博弈 + 规律)
1180. Stone Game Time limit: 1.0 second Memory limit: 64 MB Two Nikifors play a funny game. There is ...
- Ural 2045. Richness of words 打表找规律
2045. Richness of words 题目连接: http://acm.timus.ru/problem.aspx?space=1&num=2045 Description For ...
- Ural 2037. Richness of binary words 打表找规律 构造
2037. Richness of binary words 题目连接: http://acm.timus.ru/problem.aspx?space=1&num=2037 Descripti ...
- ural 2029 Towers of Hanoi Strike Back (数学找规律)
ural 2029 Towers of Hanoi Strike Back 链接:http://acm.timus.ru/problem.aspx?space=1&num=2029 题意:汉诺 ...
- URAL 2037 Richness of binary words (回文子串,找规律)
Richness of binary words 题目链接: http://acm.hust.edu.cn/vjudge/contest/126823#problem/B Description Fo ...
- URAL 2065 Different Sums (找规律)
题意:构造一个数列,使得它们的区间和的种类最少,其中数列中不同的数的数目不少于k. 析:我们考虑0这个特殊的数字,然后0越多,那么总和种类最少,再就是正负交替,那么增加0的数量. 代码如下: #pra ...
随机推荐
- SpringMVC介绍之视图解析器ViewResolver
在前一篇博客中讲了SpringMVC的Controller控制器,在这篇博客中将接着介绍一下SpringMVC视图解析器.当我们对SpringMVC控制的资源发起请求时,这些请求都会被SpringMV ...
- C#面向服务编程技术WCF从入门到实战演练
一.WCF课程介绍 1.1.Web Service会被WCF取代吗? 对于这个问题阿笨的回答是:两者在功能特性上却是有新旧之分,但是对于特定的系统,适合自己的就是最好的.不能哪一个技术框架和行业标准作 ...
- AngularJS路由系列(5)-- UI-Router的路由约束、Resolve属性、路由附加数据、路由进入退出事件
本系列探寻AngularJS的路由机制,在WebStorm下开发.主要包括: ● UI-Router约束路由参数● UI-Router的Resolve属性● UI-Router给路由附加数据● UI- ...
- AngularJS如何编译和呈现页面
AngularJS如何编译和呈现页面? 页面加载,首先加载静态DOM,AngularJS随即加载,并寻找在页面的ng-app,然后开始编译所有moudlue内的所有service, controlle ...
- 将 tomcat 安装成 windows 服务
1.下载 tomcat 的windows 压缩包,一般以 .zip ,而且文件名中有 bin 的文件就是 2.解压下载的文件到某一个目录下,eg: TOMCAT_HOME 3.打开 cmd ,运行 % ...
- 在CentOS4上安装JMagick
用Java做网站经常要处理用户上传的图片,例如生成缩略图等等.虽然Java可以使用Java2D进行一些图片操作,但是功能和效率实在太差了. 目前比较好的是用JMagick来进行图像处理,不过JMagi ...
- Chrome 如何知道网站启用了SPDY 协议?
地址栏输入chrome://net-internals/#spdy 在host后查看协议,google和dropbox用https协议的开启了 3. 也可以通过安装插件来查看(SPDY Indicat ...
- iReport数据库连接找不到驱动
- .Net Excel操作之NPOI(二)常用操作封装
一.Excel数据导出常用操作 1.指定表头和描述 2.指定数据库中读出的数据集合 二.ExcelExport封装 /// <summary> /// Excel常用的表格导出逻辑封装 / ...
- ArrayBlockingQueue, LinkedBlockingQueue, ConcurrentLinkedQueue, RingBuffer
1. ArrayBlockingQueue, LinkedBlockingQueue, ConcurrentLinkedQueue ArrayBlockingQueue, LinkedBlocking ...