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.

InputThe 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. 
OutputFor 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
#include<iostream>
#include<stdio.h>
#include<algorithm>
using namespace std;
int main()
{
int t;
int x,y;
scanf("%d",&t);
while(t--)
{
scanf("%d%d",&x,&y);
if(x==y+2||x==y)//2条线所在
{
if(x%2==1)//分奇偶找规律
printf("%d\n",(x+y)-1);
else if(x%2==0)
printf("%d\n",x+y);
}
else
printf("No Number\n");
}
return 0;
}

  

最新文章

  1. (多重背包+记录路径)Charlie&#39;s Change (poj 1787)
  2. 获取SHA1和MD5
  3. Delphi下16进制位图数据转位图
  4. 关于ZeroMQ的信息与文档
  5. 移动开发中使用Onsen UI的笔记
  6. hdu 4628 动态规划
  7. 启用EXCHANGE反垃圾邮件功能和重建EXCHANGE邮件系统帐号
  8. HTML5 Placeholder实现input背景文字提示效果
  9. LED板上芯片(COB)封装流程
  10. JavaScript学习笔记(散)——addLoadEvent函数
  11. [亲测]ASP.NET Core 2.0怎么发布/部署到Ubuntu Linux服务器并配置Nginx反向代理实现域名访问
  12. 一个实时收集MySql变更记录的组件CanalSharp.AspNetCore
  13. 一个request引发的bug
  14. Confluence 6 附件存储配置
  15. java多线程系列16 线程池
  16. Luogu4640 BJWC2008 王之财宝 容斥、Lucas
  17. day11 闭包函数和装饰器
  18. python xlwt写excel格式控制 颜色、模式、编码、背景色
  19. LearnOpenGL 你好,三角形[转]--附源码
  20. WordPress 3.8 后台仪表盘将重新设计

热门文章

  1. 更换Sublime Text主题字体
  2. poj 2965 The Pilots Brothers&#39; refrigerator (dfs)
  3. [NOIP2017 TG D2T2]宝藏
  4. 用JavaScript实现一个简单的树结构
  5. 使用 URLDecoder 和 URLEncoder 对中文字符进行编码和解码
  6. git使用笔记(九)操作原理
  7. 如何把阿里云的服务器配置为mac的共享文件夹(亲测有效)
  8. 于是他错误的点名开始了 [Trie]
  9. 毕业答辩的PPT攻略
  10. es6+最佳入门实践(7)