ZOJ Problem Set - 1414||Number Steps
来源:互联网 发布:tomcat怎么连接数据库 编辑:程序博客网 时间:2024/05/16 03:14
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: Asia 2000, Tehran (Iran)
#include <stdio.h>int main(){int n, x, y, result;scanf("%d", &n);while(n--){scanf("%d %d", &x, &y);if(x == y){if(x % 2 == 0)result = x + y;elseresult = x + y - 1;printf("%d\n", result);}else if(x - 2 == y){if(y % 2 == 0)result = x + y;elseresult = x + y - 1;printf("%d\n", result);}elseprintf("No Number\n");}return 0;}
- ZOJ Problem Set - 1414||Number Steps
- zoj 1414 Number Steps
- ZOJ 1414 Number Steps
- ZOJ 1414 Number Steps
- zoj 1414 Number Steps
- zoj 1414 Number Steps
- ZOJ 1414:Number Steps
- ZOJ 1414 Number Steps
- zoj 1414 Number Steps(水~)
- ZOJ Problem Set - 2105 Number Sequence
- ZOJ Problem Set - 3702 Gibonacci number
- ZOJ Problem Set - 2736 Daffodil number
- ZOJ Problem Set - 2736 Daffodil number
- ZOJ Problem Set - 2829 Beautiful Number
- ZOJ Problem Set - 3436 July Number
- ZOJ Problem Set - 3543 Number String DP
- ZOJ 1441 Number Steps
- ZOJ Problem Set - 3816 Generalized Palindromic Number 搜索+贪心
- 数据库复习9——关系代数和关系演算
- REST与SOAP之比较——SOAP篇
- 如何在VIM中保存编辑的只读文件
- 自定义dialog样式
- 每天一道算法题目(18)——取等长有序数组的上中位数和不等长有序数组的第k小的数
- ZOJ Problem Set - 1414||Number Steps
- LeetCode Sort Colors
- 黑马程序员——java的IO之流操作的基本规律,Properties类,打印流,序列流
- java.util.concurrent.BlockingQueue初探
- 黑马day11 不可重复度&解决方案
- 走进Struts2(四)— 自定义转换器
- vector中erase用法注意事项
- 使用aapt查看apk包名和第一个启动的activity
- ZOJ Problem Set - 2482||IP Address