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的更多相关文章

  1. ZOJ 2850和ZOJ 1414

    下午上数据结构,结果竟然没有新题.T T果断上OJ来水一发 ZOJ 2850   Beautiful Meadow 传送门http://acm.zju.edu.cn/onlinejudge/showP ...

  2. HDU-1391 Number Steps

    http://acm.hdu.edu.cn/showproblem.php?pid=1391 Number Steps Time Limit: 2000/1000 MS (Java/Others)   ...

  3. Number Steps

    Number Steps Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Tota ...

  4. POJ 1663:Number Steps

    Number Steps Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 13758   Accepted: 7430 Des ...

  5. POJ 1663:Number Steps

    Number Steps Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 13664   Accepted: 7378 Des ...

  6. 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 ...

  7. [ZOJ 2836] Number Puzzle

    Number Puzzle Time Limit: 2 Seconds      Memory Limit: 65536 KB Given a list of integers (A1, A2, .. ...

  8. HDOJ 1391 Number Steps(打表DP)

    Problem Description Starting from point (0,0) on a plane, we have written all non-negative integers ...

  9. hdu1391(Number Steps )

    Problem Description Starting from point (0,0) on a plane, we have written all non-negative integers ...

随机推荐

  1. PHP经典算法集锦【经典收藏】

    本文实例总结了PHP经典算法.分享给大家供大家参考,具体如下: 1.首先来画个菱形玩玩,很多人学C时在书上都画过,咱们用PHP画下,画了一半. 思路:多少行for一次,然后在里面空格和星号for一次. ...

  2. 源码学习-Object类

    1.Object类是Java所有类的超类 2.查看Object的属性和方法,发现Object类没有属性,只有13个方法,其中7个本地方法. 3.接下来看具体的方法 3.1 Object() 默认的构造 ...

  3. selenium--driver.switchTo()-----转

    https://www.cnblogs.com/clairejing/p/9499223.html 在自动化测试中,会遇到多窗口.多iframe.多alert的情况.此时,会使用driver.swit ...

  4. 第二周习题F

    Starting with x and repeatedly multiplying by x, we can compute x31 with thirty multiplications: x2  ...

  5. 全文搜索(A-3)-用户建模

    用户模型可以分为静态模型.动态模型.混合推荐用户模型. 静态模型往往通过显式方式收集用户偏好信息: 动态模型通过隐式方式收集用户偏好信息: 基于内容的用户系统的推荐模型: 关键字匹配,空间向量模型 协 ...

  6. centOS 7 换ssh端口

    centos 最少安装时缺少semanage的,要这样装补上,因为默认是安装了SElinux的 [root@localhost ~]# sestatus SELinux status: enabled ...

  7. Chrome & CORS & Fetch API & Chrome 多开,应用分身

    Chrome & CORS & Fetch API Chrome 浏览器的跨域设置 https://www.cnblogs.com/cshi/p/5660039.html https: ...

  8. [SPOJ7258]Lexicographical Substring Search

    [SPOJ7258]Lexicographical Substring Search 试题描述 Little Daniel loves to play with strings! He always ...

  9. [luoguP1042] 乒乓球(模拟)

    传送门 终于过了这sb题了. 当初我连这道题都A不了(╯▔皿▔)╯ 代码 #include <cstdio> #include <iostream> #define N 100 ...

  10. noip模拟赛 卖书

    分析:模拟题,只是有几个地方需要注意一下:第一个人必须支付5元,找零15元可以找一张10元一张5元,也可以找3张5元. #include <cstdio> #include <cst ...