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. CSS3 @font-face 指定英文网页字体

      @font-face是CSS3中的一个模块,他主要是把自己定义的Web字体嵌入到你的网页中,随着@font-face模块的出现,我们在Web的开发中使用字体不怕只能使用Web安全字体.可能有人要问 ...

  2. Web框架-Django基础

    一.django简介 Django是一个开放源代码的Web应用框架,由Python写成.采用了MVC的软件设计模式,即模型M,视图V和控制器C.它最初是被开发来用于管理劳伦斯出版集团旗下的一些以新闻内 ...

  3. haproxy之配置文件解析

    功能--> 提供高可用/负载均衡/基于tcp和http应用的代理;支持虚拟主机,特别适用于负载特大的web站点. 配置文件解析--> #配置文件-->开启/proc/net/ipv4 ...

  4. python3.4+pyspider爬58同城(二)

    之前使用python3.4+selenium实现了爬58同城的详细信息,这次用pyspider实现,网上搜了下,目前比较流行的爬虫框架就是pyspider和scrapy,但是scrapy不支持pyth ...

  5. DIRECTORY_SEPARATOR的作用

    IRECTORY_SEPARATOR是php的内部常量,用于显示系统分隔符的命令,不需要任何定义与包含即可直接使用. 在windows下路径分隔符是/(当然/在部分系统上也是可以正常运行的),在lin ...

  6. 掌握string.h里的常用函数

    字符串输出函数 puts 格式:  puts(字符数组名) 功能:把字符数组中的字符串输出到显示器. 即在屏幕上显示该字符串. 字符串输入函数 gets 格式:  gets (字符数组名) 功能:从标 ...

  7. mysql不能链接远程,报(Host '***.***.***.***' is not allowed to connect to this MySQL server)

    Host '***.***.***.***' is not allowed to connect to this MySQL server 其中***...是本机公网ip; 解决办法: 首先看报错窗口 ...

  8. [转]让Sublime Text2支持浏览器中预览

    转自http://www.imququ.com/post/view-sublime-text-2-file-in-browser.html 1.点击菜单Tools -> New Plugin.. ...

  9. Yslow-23条规则编辑

    1. 减少HTTP请求次数 合并图片.CSS.JS,改进首次访问用户等待时间.   2. 使用CDN 就近缓存==>智能路由==>负载均衡==>WSA全站动态加速   3. 避免空的 ...

  10. 关于Keil C51中using关键字的使用心得

    刚才看到一位很牛的师兄写的一篇日志中提到了Keil C51中using这个关键字的用法,粗心的我本来一直都没有留意它是用来干嘛的(因为我一般看见它都是在中断服务函数的定义开头处,好像没有了它也可以中断 ...