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

Description

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

洪水题,找规律。

代码:

#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <cstring>
#pragma warning(disable:4996)
using namespace std; int main()
{
//freopen("i.txt","r",stdin);
//freopen("o.txt","w",stdout); int Test,x,y;
cin>>Test; while(Test--)
{
cin>>x>>y;
if((x==y||x-2==y)&&x>=0&&y>=0)
{
if(x==y)
{
if(x%2)
{
cout<<x*2-1<<endl;
}
else
{
cout<<x*2<<endl;
}
}
else
{
if(x%2)
{
cout<<x*2-3<<endl;
}
else
{
cout<<x*2-2<<endl;
}
}
}
else
{
cout<<"No Number"<<endl;
}
}
return 0;
}

版权声明:本文为博主原创文章,未经博主允许不得转载。

最新文章

  1. 《你不知道的JavaScript》整理(一)——作用域、提升与闭包
  2. .net framework 3.5 序列化
  3. 【poj1733】 Parity game
  4. CocoStudio基础教程(5)使用CocoStudio场景编辑器关联组件
  5. C# 获取打印机状态
  6. Acdream a + b
  7. hdu Fibonacci
  8. GCC 命令行具体解释
  9. linux杂记(七)linux档案与目录管理指令
  10. BIGIP-LTM中的NAT和SNAT
  11. 修改Linux命令提示符
  12. Unity中雾效的开启
  13. [转]git 删除远程仓库文件
  14. 知识点补充 set 深浅拷贝
  15. Flink(三)Flink开发IDEA环境搭建与测试
  16. Scala常用变量生命周期
  17. React Native Android启动白屏的一种解决方案下
  18. POJ 3311 Hie with the Pie 先用floyd预处理,再状态压缩
  19. [JAVA] JAVA 类路径
  20. js createElement appendChild createTextNode用法

热门文章

  1. PAT (Advanced Level) 1140~1143:1140模拟 1141模拟 1142暴力 1143 BST+LCA
  2. nested exception is javax.management.InstanceAlreadyExistsException: webservice:name=statFilter,type=StatFilter
  3. Eclipse 不能调试的问题
  4. mysql 存储引擎入门
  5. mysql 模糊查询中包含特殊字符查询
  6. mysql sql语句不同平台上大小写区分
  7. git commit -m 和 git commit -am 区别
  8. JuJu团队11月30号工作汇报
  9. java时间差
  10. Oracle 新建用户、赋予权限