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. 从植发AI看智能手术机器人的国产化之路

    在工作和生活的双重压力下,很多80后乃至90后的青年都"光荣"地加入了"脱发一族".为了拯救发际线或是不变成"地中海",很多人从此走上了寻医 ...

  2. element设置headers添加token

    <template>   <div>     <el-upload       action="http://localhost:3000/picture&qu ...

  3. Koa微信公众号开发

    微信开发者模式开启需要服务器域名合法并且把接口配置好,这个接口是接通的关键,接通后微信后台的菜单设置功能,客服功能会失效,需要开发者自定义菜单和智能客服界面,并且接通后可以调用微信网页内部的定位分享等 ...

  4. 005.CI4框架CodeIgniter, 通过带路径的view视图访问

    01. 我们在app目录的Views文件夹中新建一个Login文件,再创建一个login.php文件,在里面我们写上如下代码: <!doctype html> <html> & ...

  5. Spark Scheduler 模块(上)

    在阅读 Spark 源代码的过程中,发现单步调试并不能很好的帮助理解程序.这样的多线程的分布式系统,更好的阅读源代码的方式是依据模块,分别理解.   在包 org.apache.spark 下面有很多 ...

  6. yum 安装 tomcat

    前言对于一个新安装的 centos 系统来说,是没有 tomcat 服务器的.用下面的命令可以查看 tomcat 服务的状态. systemctl status tomcat.service//或者 ...

  7. 利用jQuery实现PC端href生效,移动端href失效

    今天要写一个功能,记录一下吧.if(navigator.userAgent.match(/(iPhone|iPod|Android|ios)/i)){ $('.item-a').attr('href' ...

  8. emacs 配置文件目录

    在 windows 环境下,emacs 的配置目录可以通过下面几种方式来设置: If the environment variableHOME is set, use the directory it ...

  9. Numpy使用大全(python矩阵相关运算大全)-Python数据分析基础2

    //2019.07.10python数据分析基础——numpy(数据结构基础) import numpy as np: 1.python数据分析主要的功能实现模块包含以下六个方面:(1)numpy—— ...

  10. Golang函数-函数的基本概念

    Golang函数-函数的基本概念 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.函数的概述 1>.函数定义语法格式 Go语言函数定义格式如下: func 函数名( 函数参 ...