Number Steps

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 4482    Accepted Submission(s):
2732

Problem 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 <cstdio>
using namespace std;
int main()
{
int x,y;
int T;
cin>>T;
while(T--)
{
cin>>x>>y;
if(x-y==||x-y==)
{
if(x-y==)
{
if(x%==)
cout<<*x<<endl;
else
cout<<*x-<<endl;
}
else
{
if(x%==)
cout<<x+y<<endl;
else
cout<<x+y-<<endl;
}
}
else
printf("No Number\n");
}
}

Number Steps的更多相关文章

  1. HDU-1391 Number Steps

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

  2. ZOJ 1414:Number Steps

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

  3. POJ 1663:Number Steps

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

  4. POJ 1663:Number Steps

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

  5. HDOJ 1391 Number Steps(打表DP)

    Problem Description Starting from point (0,0) on a plane, we have written all non-negative integers ...

  6. hdu1391(Number Steps )

    Problem Description Starting from point (0,0) on a plane, we have written all non-negative integers ...

  7. HDU 1391 number steps(找规律,数学)

    Starting from point (0,0) on a plane, we have written all non-negative integers 0, 1, 2,... as shown ...

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

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

  9. hdu 1391 Number Steps(规律)

    题意:找规律 思路:找规律 #include<iostream> #include<stdio.h> using namespace std; int main(){ int ...

随机推荐

  1. 一些常用Linux命令简记

    1.重命名文件夹 mv xxx/ yyy/  将xxx文件夹重命名为yyy(前提是当前目录没有yyy文件夹,否则就移进去了!) 2.数据盘重新挂载 一.# umount /mnt(卸载硬盘已挂载的mn ...

  2. XML的特殊字符

    XML中共有5个特殊的字符,分别是:&<>“’.如果配置文件中的注入值包括这些特殊字符,就需要进行特别处理.有两种解决方法: 其一,采用本例中的<![CDATA[ ]]> ...

  3. js 属性类型

    1.访问器属性 var book = { _year: 2004, edition: 1 }; Object.defineProperty(book, "year", { get: ...

  4. 线程池之ThreadPool类与辅助线程 - <第二篇>

    一.CLR线程池 管理线程开销最好的方式: 尽量少的创建线程并且能将线程反复利用(线程池初始化时没有线程,有程序请求线程则创建线程): 最好不要销毁而是挂起线程达到避免性能损失(线程池创建的线程完成任 ...

  5. Php开发官方IDE ZEND

    From http://www.zend.com/en/products/studio 注:唯一的缺点是收费.

  6. yum安装配置mongoDB客户端和服务器端

    1,Centos6.X yum安装mongoDB客户端和服务器端; yum -y install mongodb mongodb-server; 基于epel repo.当前的mongoDB的版本为2 ...

  7. 如何把apache和nginx 加入到系统服务,用service 命令来控制启动、停止

    1 把apache 加入到系统服务,即用service 命令来控制Apache 启动.停止  如果Linux服务器上默认安装了httpd的话(用rpm -qa|grep httpd查看),那你就可以用 ...

  8. npm 常用命令详解[转]

    npm是什么 NPM的全称是Node Package Manager,是随同NodeJS一起安装的包管理和分发工具,它很方便让JavaScript开发者下载.安装.上传以及管理已经安装的包. npm ...

  9. 用c++语言编写函数 int index(char *s,char * t),返回字符串t在字符串s中出现的最左边的位置,如果s中没有与t匹配的子串,则返回-1。类似于索引的功能。

    首先,分析一下程序的思路: 1:从s的第i个元素开始,与t中的第1个元素匹配,如果相等,则将s的第i+1元素与t中的第2个元素匹配,以此类推,如果t所有元素都匹配,则返回位置i;否则,执行2; 2: ...

  10. IOS 使用dispatch_once 创建单例

    + (instantClass *)sharedClient { static instantClass *_sharedClient = nil; static dispatch_once_t on ...