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 ...
随机推荐
- [Asp.net mvc]Html.ValidationSummary(bool)
摘要 对ValidationSummary是HtmlHelper的扩展方法,用来返回 System.Web.Mvc.ModelStateDictionary (即ModelState)对象中的验证消息 ...
- canvas使用2
文字对齐方式 : 水平对齐 ? 1 2 3 4 //是用 textAlign 属性设置水平对齐方式(默认坐标点) ctx.textAlign = "start"; ctx.font ...
- uifont 字体详解
时间2013-06-04 11:26:33 CSDN博客原文 http://blog.csdn.net/u010013695/article/details/9020611 我们在开发中很多时候要设 ...
- C#编程(三十七)----------结构比较
结构比较 数组和元组都实现接口IStructuralEquatable和IStructuralComparable.这两个接口不仅可以比较引用,还可以比较内容.这些接口都是显示实现的,所以在使用时需要 ...
- 初识安卓小程序(Android电话拨号器)
首先,先创建一个安卓项目(我的版本号是4.4.2的),名字为"电话拨号器",创建的时候点击"clipart",如图: 然后在res目录下找到layout目录,找 ...
- [Android Security] APK自我保护 - DEX/APK校验
cp : https://segmentfault.com/a/1190000005105973 DEX校验 classes.dex 是 Android 虚拟机的可执行文件,我们所写的 java 代码 ...
- [转] OpenStack IPSec VPNaaS
OpenStack IPSec VPNaaS ( by quqi99 ) 作者:张华 发表于:2013-08-03版权声明:可以任意转载,转载时请务必以超链接形式标明文章原始出处和作者信息及本版权声 ...
- PHP检测及判断手机登录用户是安卓或爱疯(iPhone)客户端
<?php /* PHP 自动判断客户端平台(PC.安卓.iPhone.平板) * strtolower() 函数把字符串转换为小写: * strpos() 函数返回字符串在另一个字符串中第一次 ...
- float浮点数的四舍五入
瑞生网http://www.rationmcu.com版权所有 前几天,有个小伙伴在做实验过程中,发现了一个奇怪的现象,这个现象就是… 他在用printf输出浮点数的时候,想把数据保留到小数点后的两位 ...
- [leetcode]Insert Interval @ Python
原题地址:https://oj.leetcode.com/problems/insert-interval/ 题意: Given a set of non-overlapping intervals, ...