ZOJ 1414:Number Steps
Number Steps
Time Limit: 2 Seconds Memory Limit: 65536 KB
Starting from point (0,0) on a plane, we have written all non-negative integers 0, 1, 2,... as shown in the figure. For example, 1, 2, and 3 has been written at points (1,1), (2,0), and
(3, 1) respectively and this pattern has continued.
You are to write a program that reads the coordinates of a point (x, y), and writes the number (if any) that has been written at that point. (x, y) coordinates in the input are in the
range 0...5000.
Input
The first line of the input is N, the number of test cases for this problem. In each of the N following lines, there is x, and y representing the coordinates (x, y) of a point.
Output
For each point in the input, write the number written at that point or write No Number if there is none.
Sample Input
3
4 2
6 6
3 4
Sample Output
6
12
No Number
Source: Asia 2000, Tehran (Iran)
你 离 开 了 , 我 的 世 界 里 只 剩 下 雨 。 。 。
#include<iostream>
using namespace std;
int main()
{
int n;
cin>>n;
while(n--)
{
int a,b;
cin>>a>>b;
if(a==b||a-b==2)
{
if(a==b)
{
if(a&1)cout<<2*a-1<<endl;
else cout<<2*a<<endl;
}
else
{
if(b&1)cout<<2*a-3<<endl;
else cout<<2*a-2<<endl;
}
}
else cout<<"No Number"<<endl;
}
return 0;
}
ZOJ 1414:Number Steps的更多相关文章
- ZOJ 2850和ZOJ 1414
下午上数据结构,结果竟然没有新题.T T果断上OJ来水一发 ZOJ 2850 Beautiful Meadow 传送门http://acm.zju.edu.cn/onlinejudge/showP ...
- HDU-1391 Number Steps
http://acm.hdu.edu.cn/showproblem.php?pid=1391 Number Steps Time Limit: 2000/1000 MS (Java/Others) ...
- Number Steps
Number Steps Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Tota ...
- POJ 1663:Number Steps
Number Steps Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 13758 Accepted: 7430 Des ...
- POJ 1663:Number Steps
Number Steps Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 13664 Accepted: 7378 Des ...
- ZOJ 3908 Number Game ZOJ Monthly, October 2015 - F
Number Game Time Limit: 2 Seconds Memory Limit: 65536 KB The bored Bob is playing a number game ...
- [ZOJ 2836] Number Puzzle
Number Puzzle Time Limit: 2 Seconds Memory Limit: 65536 KB Given a list of integers (A1, A2, .. ...
- HDOJ 1391 Number Steps(打表DP)
Problem Description Starting from point (0,0) on a plane, we have written all non-negative integers ...
- hdu1391(Number Steps )
Problem Description Starting from point (0,0) on a plane, we have written all non-negative integers ...
随机推荐
- HDU - 4544 湫湫系列故事——消灭兔子(优先队列+贪心)
题目: 最近,减肥失败的湫湫为发泄心中郁闷,在玩一个消灭免子的游戏. 游戏规则很简单,用箭杀死免子即可. 箭是一种消耗品,已知有M种不同类型的箭可以选择,并且每种箭都会对兔子造成伤害,对应的伤害值分别 ...
- galera cluster安装与配置
由于公司数据量与并发的日渐增大,普通的主从复制已无法满足要求.对比了网上PXC.galera.mysql cluster等方案,最终决定选择galera cluster. 以下为安装步骤: 1.下载g ...
- python多线程和多进程(一)
一.多线程 Python的标准库提供了两个模块:_thread和threading,_thread是低级模块,threading是高级模块,对_thread进行了封装.绝大多数情况下,只需要使用thr ...
- JavaScript中的特殊数据类型
JavaScript中的特殊数据类型 制作人:全心全意 转义字符 以反斜杠开头的不可显示的特殊字符通常为控制字符,也被称为转义字符.通常转义字符可以在字符串中添加不可显示的特殊字符,或者防止引号匹配混 ...
- 4.model 字段
一.字段名 字段名 类型 参数 AutoField(Field) - int自增列, 必须填入参数 primary_key=True BigAutoField(AutoField) - bigint自 ...
- 前端性能分析-HTTPWatch和dynaTrace
- Apple & APPID & iOS & React Native
Apple & APPID & iOS & React Native 在没有 苹果开发者账号证书 APPID, ios 是否支持导出 app https://developer ...
- Codeforces Gym100495 B、D、E、F、K
http://codeforces.com/gym/100495 K题 草地的面积减去相交的面积,计算几何,垃圾题,避免不必要的计算损失精度(能约分的约分) 卡了老子一个星期了 再加前几天的一道题 这 ...
- [bzoj1874][BeiJing2009 WinterCamp]取石子游戏_博弈论
取石子游戏 bzoj-1874 BeiJing2009 WinterCamp 题目大意:题目链接. 注释:略. 想法: 我们通过$SG$函数的定义来更新$SG$的转移. 如果是寻求第一步的话我们只需要 ...
- 04-js的运算符
<html> <head> <title>js的运算符学习</title> <meta charset="UTF-8"/> ...