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

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

Source

你  离  开  了  ,  我  的  世  界  里  只  剩  下  雨  。  。  。

#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;
}

POJ 1663:Number Steps的更多相关文章

  1. POJ 1663:Number Steps

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

  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 1019 Number Sequence( 数据分析和操作)

    一.题目大意 有这样一个序列包含S1,S2,S3...SK,每一个Si包括整数1到 i.求在这个序列中给定的整数n为下标的数. 例如,前80位为1121231234123451234561234567 ...

  5. ZOJ 1414:Number Steps

    Number Steps Time Limit: 2 Seconds      Memory Limit: 65536 KB Starting from point (0,0) on a plane, ...

  6. poj 1019 Number Sequence 【组合数学+数字x的位宽函数】

    题目地址:http://poj.org/problem?id=1019 Number Sequence Time Limit: 1000MS   Memory Limit: 10000K Total ...

  7. POJ 1019 Number Sequence

    找规律,先找属于第几个循环,再找属于第几个数的第几位...... Number Sequence Time Limit: 1000MS Memory Limit: 10000K Total Submi ...

  8. POJ 1663

    #include<iostream>//cheng da cai zi using namespace std; int main() { int time; cin>>tim ...

  9. POJ 1220 NUMBER BASE CONVERSION(较复杂的进制转换)

    题目链接 题意 : 给你一个a进制的数串s,让你转化成b进制的输出. A = 10, B = 11, ..., Z = 35, a = 36, b = 37, ..., z = 61,0到9还是原来的 ...

随机推荐

  1. RabbitMQ系列(八)--顺序消费模式和迅速消息发送模式

    MQ使用过程中,有些业务场景需要我们保证顺序消费,而如果一个Producer,一个Queue,多个Consumer的情况下是无法保证顺序的 举例: 1.业务上产生三条消息,分别是对数据的增加.修改.删 ...

  2. 干货分享--iOS及Mac开源项目和学习资料【超级全面】

    原文出处:codecloud http://www.kancloud.cn/digest/ios-mac-study/84557

  3. P1091 合唱队形题解(洛谷,动态规划LIS,单调队列)

    先上题目 P1091 合唱队形(点击打开题目) 题目解读: 1.由T1​<...<Ti​和Ti​>Ti+1​>…>TK​可以看出这题涉及最长上升子序列和最长下降子序列 2 ...

  4. 12Cookie、Session

    12Cookie.Session-2018/07/24 1.保存会话数据 cookie客户端技术,把每个用户的数据以cookie的形式写给用户各自的浏览器 HttpSession服务端技术,服务器运行 ...

  5. C++ 迭代器运算符 箭头运算符->

    所有标准库容器都支持迭代器,只有少数几种才支持下标运算 迭代器运算符 运算符 作用 *iter 返回迭代器iter所指元素的引用 iter -> mem 解引用iter,并获取元素名为mem的成 ...

  6. 每日命令:(8)cp

    cp命令用来复制文件或者目录,是Linux系统中最常用的命令之一.一般情况下,shell会设置一个别名,在命令行下复制文件时,如果目标文件已经存在,就会询问是否覆盖,不管你是否使用-i参数.但是如果是 ...

  7. Diango REST framework 视图继承图

  8. db2 in out inout

    总结: in  给存储过程传的参数,传一个确定的值 out  传的时候传一个非确定的变量v或者“?”  .在存储过程里面计算一个结果赋给v,这个变量v在存储过程执行完之后就是一个确定的值了. inou ...

  9. LINUX-RPM 包 - (Fedora, Redhat及类似系统)

    rpm -ivh package.rpm 安装一个rpm包 rpm -ivh --nodeeps package.rpm 安装一个rpm包而忽略依赖关系警告 rpm -U package.rpm 更新 ...

  10. springcloud(十):熔断监控Hystrix Dashboard

             申明: 这里比较坑爹,大家写的时候要小心,这里和springboot的版本有关系哈,我使用的是2.0 版本,要么调频为1.5 版本,要么使用其他方式 解决错误,我选择了还是用2.0  ...