博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
poj 1663 Number Steps
阅读量:5250 次
发布时间:2019-06-14

本文共 1376 字,大约阅读时间需要 4 分钟。

Number Steps

Time Limit: 1000MS

Memory Limit: 10000K

Total Submissions: 11605

Accepted: 6167

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

34 26 63 4

Sample Output

612No Number
1: #include
2: using namespace std;
3: int main()
4: {
5: 	int n;
6: 	int x,y;
7: 	cin>>n;
8: 	while(n--)
9: 	{
10: 		cin>>x>>y;
11: 		if(x-y!=0 && x-y!=2)
12: 			cout<<"No Number"<
13: 		else if(y%2==0 && x-y==0)
14: 			cout<<2*y<
15: 		else if(y%2==0 && x-y==2)
16: 			cout<<2*y+2<
17: 		else if(y%2==1 && x-y==0)
18: 			cout<<2*y-1<
19: 		else if(y%2==1 && x-y==2)
20: 			cout<<2*y+1<
21: 	}
22: 	return 0;
23: }
24:

转载于:https://www.cnblogs.com/w0w0/archive/2011/11/21/2257668.html

你可能感兴趣的文章
PS 滤镜— — sparkle 效果
查看>>
网站产品设计
查看>>
代理ARP
查看>>
go 学习笔记(4) ---项目结构
查看>>
java中静态代码块的用法 static用法详解
查看>>
Java线程面试题
查看>>
Paper Reading: Relation Networks for Object Detection
查看>>
day22 01 初识面向对象----简单的人狗大战小游戏
查看>>
mybatis源代码分析:深入了解mybatis延迟加载机制
查看>>
Flask三剑客
查看>>
Hibernate-缓存
查看>>
【BZOJ4516】生成魔咒(后缀自动机)
查看>>
提高PHP性能的10条建议
查看>>
svn“Previous operation has not finished; run 'cleanup' if it was interrupted“报错的解决方法...
查看>>
熟用TableView
查看>>
Java大数——a^b + b^a
查看>>
poj 3164 最小树形图(朱刘算法)
查看>>
服务器内存泄露 , 重启后恢复问题解决方案
查看>>
android一些细节问题
查看>>
KDESVN中commit时出现containing working copy admin area is missing错误提示
查看>>