http://acm.hdu.edu.cn/showproblem.php?pid=1391

Number Steps

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

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
 
Source
 
Recommend
 //看图找规律。x与y的关系。。。
#include<stdio.h>
int main()
{
int T,x,y;
scanf("%d",&T);
while(T--)
{
scanf("%d%d",&x,&y);
if(x!=y&&y+!=x)
{
printf("No Number\n");
}
else if(x==y)
{
if(x%==)
printf("%d\n",x+y);
else
printf("%d\n",x+y-);
}
else
{
if(x%==)
printf("%d\n",*x-);
else
printf("%d\n",*x-);
}
}
return ;
}

HDU-1391 Number Steps的更多相关文章

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

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

  2. hdu 1391 Number Steps(规律)

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

  3. HDOJ 1391 Number Steps(打表DP)

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

  4. HDU 1711 Number Sequence(数列)

    HDU 1711 Number Sequence(数列) Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Ja ...

  5. HDU 1005 Number Sequence(数列)

    HDU 1005 Number Sequence(数列) Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Jav ...

  6. Number Steps

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

  7. HDU 1005 Number Sequence(数论)

    HDU 1005 Number Sequence(数论) Problem Description: A number sequence is defined as follows:f(1) = 1, ...

  8. HDU 4054 Number String

    HDU 4054 Number String 思路: 状态:dp[i][j]表示以j结尾i的排列 状态转移: 如果s[i - 1]是' I ',那么dp[i][j] = dp[i-1][j-1] + ...

  9. HDU 1711 Number Sequence (字符串匹配,KMP算法)

    HDU 1711 Number Sequence (字符串匹配,KMP算法) Description Given two sequences of numbers : a1, a2, ...... , ...

随机推荐

  1. 使windows server 2003 开机不显示登录页面

    1.运行“regedit”,以打开“注册表管理器”:运行注册表编辑器,依次展开[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\WindowsNT\CurrentVersi ...

  2. PAT_1046 划拳

    啦啦啦.今天晚上火车回学校了.= =还是挺舍不得家里的. 题目描述: 划拳是古老中国酒文化的一个有趣的组成部分.酒桌上两人划拳的方法为:每人口中喊出一个数字,同时用手比划出一个数字.如果谁比划出的数字 ...

  3. (hdu)5652 India and China Origins 二分+dfs

    题目链接:http://acm.split.hdu.edu.cn/showproblem.php?pid=5652 Problem Description A long time ago there ...

  4. 九度OJ 1452 搬寝室 -- 动态规划

    题目地址:http://ac.jobdu.com/problem.php?pid=1452 题目描述: 搬寝室是很累的,xhd深有体会.时间追述2006年7月9号,那天xhd迫于无奈要从27号楼搬到3 ...

  5. AOP学习过程中遇到的问题汇总

    jdk版本问题:     在spring较低的版本中,仅支持jdk1.5到1.7版本,由于我本机安装的是jdk1.8,所以在调试的时候就会提示jdk版本要高于1.5.于是换成spring4.0,在co ...

  6. svn 日志 offline 错误

    http://zhidao.baidu.com/question/200406861.html (转) #anon-access = read anon-access = none #把read改成n ...

  7. tq --uboot使用

    - Nand Flash命令- nand info nand erase nand read[.jffs2] addr off size              .jffs代表ECC方式不同 nan ...

  8. 字符串长度计算、截取、url参数获取、计算百分比、时间戳格式化

    1.中英混合文字字符截取 //中文长度截取计算,可取中英混合,个数向上取整,精确度1个英文字符误差,一个英文算一个字符,一个汉字算一个字符. //sub("中文zlsd",1) - ...

  9. http 和 Tcp 的区别

    http 和 tcp 的区别: Http在每一次请求结束后都会主动释放连接,因此HTTP连接是一种“短链接”,要保持客户端程序的在线状态,需要不断地向服务器端发起连接请求. TCP连接时一种“长连接” ...

  10. JavaScript中将JSON的字符串解析成JSON数据格式

    1.一种为使用eval()函数 var jsonObj=eval("("+data+")"); 2.使用Function对象来进行返回解析 var jsonst ...