九度oj 1136
2015-08-23 21:12
344 查看
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.
输入:
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.
输出:
For each point in the input, write the number written at that point or write No Number if there is none.
样例输入:
样例输出:
来源:
2008年北京大学软件所计算机研究生机试真题
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.
输入:
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.
输出:
For each point in the input, write the number written at that point or write No Number if there is none.
样例输入:
3 4 2 6 6 3 4
样例输出:
6 12 No Number
来源:
2008年北京大学软件所计算机研究生机试真题
#include<iostream> using namespace std; int main(){ int n; while(cin>>n){ int x,y; for(int i=0;i<n;i++){ cin>>x>>y; if(x==y||x-y==2){ if(x%2==0) cout<<x+y<<endl; else cout<<x+y-1<<endl; } else cout<<"No Number"<<endl; } } }
相关文章推荐
- [LeetCode] Sort Colors(!!两个指针)
- hdu 1385 Minimum Transport Cost(最短路,floyd打印字典序路径)
- 裸机开发前准备
- 基于iOS的OpenCV之人脸检测(二)
- CentOS6.5实现PXE+Kickstart无人值守安装操作系统
- hdu 5420 Victor and Proposition 线段树建图+强连通分量
- Java学习笔记----容器
- 连接postgresql数据库
- 8.23单词
- C# 之 FTP服务器中文件上传与下载(二)
- HDU Victor and World (最短路+状态压缩)
- 触摸时白色圆圈的中心不在十字架中心的问题
- c++返回引用和返回对象的区别
- UIButton 点击没反应
- 【Leetcode】Search for a range
- 【GlusterFS学习之五】:trashdir回收站目录只读权限以及白名单的设计与实现
- java基础-API-集合框架-Map、Collections、Arrays
- MVC5 布署在windows2008 IIS7.5 出现的问题解决
- 交叉编译busybox流程以及出现问题的解决方法
- Nginx开发从入门到精通十三