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 ...
随机推荐
- User Agent Strings列表 — Kejun's Blog
曾经,ME 就需要这里的东西了. http://www.useragentstring.com/pages/All/
- Android:Attribute is missing the Android namespace prefix
今天编写XML文件时,出现了Attribute is missing the Android namespace prefix的错误,开始一直找没找出原因,后来仔细一看原来只是一个很简单的单词书写错误 ...
- C#编程(二十二)----------继承的类型
继承的类型 在面向对象的编程中,有两种截然不同的集成类型:实现继承和接口继承 实现继承:表示一个类型派生于一个基类型,它拥有该基类型的所有成员字段和函数.在实现继承中,派生类型采用基类型的每个函数的实 ...
- arcgis10.5.1 对齐要素
许可级别:BasicStandardAdvanced 摘要 标识地理处理工具用于标识搜索距离中输入要素与目标要素的不一致部分并使其与目标要素一致. 插图 用法 警告: 此工具用于修改输入数据.有关详细 ...
- 一文犀利看懂中美贸易战 z
如今的中国面对着前所未有的经济全球化的大环境.面对着如何成为创新性国家的重任. 钛媒体注:美国东部时间 7 月 6 日凌晨0:01 分,美国正式开始对 340 亿美元的中国产品加征 25% 的关税,这 ...
- Python:Opening Python Classes
I won’t reply to that post much, because it’s mostly… well, not useful to respond to. But people oft ...
- python测试开发django-25.表单提交之post注册案例
前言 一个网站上新用户注册,会写个注册页面,如果用django写个注册页面的流程呢? 本篇以post请求示例,从html页面上输入用户注册信息,提交到后台处理数据,然后传参数据到User数据库表里面 ...
- java单例模式实例
什么是单例模式? 定义:确保一个类只有一个实例,而且自行实例化并向整个系统提供这个实例场景,也就是说:确保某个类有且只有一个对象的场景,避免产生多个对象消耗过多的资源,或者某种类型的对象应该有且只有一 ...
- Java泛型的一些限制
本文主要參考<Java编程思想(第4版)>的Java泛型章节,仅当一个简单的读书笔记. 和C++泛型对照,Java泛型仅仅是一种编译期间的擦拭机制. 这是因为考虑到和曾经的兼容而考虑的一种 ...
- Easyui dialog Y轴滚动条定位
使用Easyui dialog进行数据新增的时候,如果Y轴方向有滚动条,当关闭之前的时候,将滚动条拉到最下方,再次打开的时候,滚动条还是定位在最下方. 需求: 每次打开的时候dialog Y轴滚动条定 ...