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. find系列之xargs命令

    xargs的功能-->     将标准输入转换为命令行参数,供后面的命令调用,但是一次只能依据-d和-n限定的行数来推送一行 xargs的作用-->     使那些不能利用stdin的命令 ...

  2. thinkphp项目目录

    #   ThinkPHP核心文件介绍        ├─ThinkPHP.php     框架入口文件    ├─Common 框架公共文件    ├─Conf 框架配置文件    ├─Extend ...

  3. Mysql基本类型(五种年日期时间类型)——mysql之二

    转自:<MySQL技术内幕:时间和日期数据类型> http://tech.it168.com/a2012/0904/1393/000001393605_all.shtml

  4. js void运用

    谈谈Javascript中的void操作符 http://segmentfault.com/a/1190000000474941 总结: void有如下作用: 通过采用void 0取undefined ...

  5. hdu Hat's Fibonacci

    import java.math.BigInteger; import java.util.*; public class Main { public static void main(String ...

  6. log4cplus配置文件使用

    简介 log4cplus是log4j的c++移植版,是c++中一个很好的打印日志的库.它与另外一个c++的log库log4cxx相比较,好处是不依赖于libapr和libaprutil,可以静态链接到 ...

  7. cf478D Red-Green Towers

    D. Red-Green Towers time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

  8. BFS visit tree

    There are two ways to conduct BFS on tree. Solution 1 -- Given level Use recursion to find given lev ...

  9. 将Oracle JDBC驱动库安装到本地仓库

    1.为了添加详细版本信息,先查看当前Oracle数据库版本 select * from v$version; 查询返回如下信息 BANNER ----------------------------- ...

  10. 关于xhEditor

    关于xhEditor xhEditor是一个基于jQuery开发的简单迷你并且高效的在线可视化HTML编辑器,基于网络访问并且兼容IE 6.0+,Firefox 3.0+,Opera 9.6+,Chr ...