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

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

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

  1. POJ 1019:Number Sequence 二分查找

    Number Sequence Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 36013   Accepted: 10409 ...

  2. 九度OJ 1136:Number Steps(步数) (基础题)

    时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:691 解决:412 题目描述: Starting from point (0,0) on a plane, we have written ...

  3. POJ 1663:Number Steps

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

  4. poj 2104 K-th Number 主席树+超级详细解释

    poj 2104 K-th Number 主席树+超级详细解释 传送门:K-th Number 题目大意:给出一段数列,让你求[L,R]区间内第几大的数字! 在这里先介绍一下主席树! 如果想了解什么是 ...

  5. POJ 3252:Round Numbers

    POJ 3252:Round Numbers Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 10099 Accepted: 36 ...

  6. 原生JS:Number对象详解

    Number对象 本文参考MDN做的详细整理,方便大家参考MDN JavaScript 的 Number 对象是经过封装的能让你处理数字值的对象.Number 对象由 Number() 构造器创建. ...

  7. HDU-1391 Number Steps

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

  8. Number Steps

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

  9. JavaScript:Number 对象

    ylbtech-JavaScript:Number 对象 1. Number 对象返回顶部 Number 对象 Number 对象是原始数值的包装对象. 创建 Number 对象的语法: var my ...

随机推荐

  1. OS、浏览器排名:Win10狂飙、Chrome逆天

    根据 Netmarketshare公布的最新数据,2019年7月,Windows 10系统市场份额获得显著增长,市场份额创下新高:Windows 7则进一步衰退,份额下滑高达3.6%,这也是其历史上最 ...

  2. mysql悲观锁处理赠品库存超卖的情况

    处理库存超卖的情况前,先了解下什么是乐观锁和悲观锁,下面的几篇博客已经介绍的比较详细了,我就不在赘述其原理了 [MySQL]悲观锁&乐观锁 对mysql乐观锁.悲观锁.共享锁.排它锁.行锁.表 ...

  3. Python面试常问的10个问题

    很多人想找Python工作,面试往往在基础知识点采坑了 Python是个非常受欢迎的编程语言,随着近些年机器学习.云计算等技术的发展,Python的职位需求越来越高.下面我收集了10个Python面试 ...

  4. 011、MySQL取14天前Unix时间戳

    #取14天前时间戳 SELECT unix_timestamp( DATE_SUB( curdate( ), INTERVAL DAY ) ); 效果如下: 不忘初心,如果您认为这篇文章有价值,认同作 ...

  5. DataTable.Copy()

    DataTable dtpocopy = dtPO.Copy(); DataRow[] dr = dtpocopy .Select("客户名称='" + cusName + &qu ...

  6. G - Traffic

    vin is observing the cars at a crossroads. He finds that there are n cars running in the east-west d ...

  7. POJ 2305:Basic remains 进制转换

    Basic remains Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 5221   Accepted: 2203 Des ...

  8. Andriod studio 汉化教程

    1.找到安装目录,D:\Program Files\Android\Android Studio\lib,先保存resources_en,并且把它的名字改为resources_cn.jar 2.下载汉 ...

  9. Ctags命令

    ctags -R 生成目录下的tags文件 只生成php文件的 tags文件 ctags --langmap=php:.engine.inc.module.theme.php --php-kinds= ...

  10. JVM学习与问题总结——java内存区域与内存溢出异常

    java虚拟机将内存分为哪些区域? 根据Java SE7版本的Java虚拟机规范,虚拟机管理的内存包括5个运行时数据区域: 程序计数器 虚拟机栈 本地方法栈 方法区 堆 运行时数据区各部分的作用? 程 ...