【POJ】1663 - Number Steps(找规律)
来源:互联网 发布:apache atlas 编辑:程序博客网 时间:2024/05/24 15:40
点击打开题目
Number Steps
Time Limit: 1000MS Memory Limit: 10000KTotal Submissions: 13816 Accepted: 7470
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.
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
Source
Tehran 2000
WA的一次心服口服,刚开始只是判断 x ,y 的奇偶性是否相同,后来发现并不能这么判断,UVALive 的数据比较弱,POJ的强一点。
代码如下:
#include <cstdio>int main(){int u;int x,y;scanf ("%d",&u);while (u--){scanf ("%d %d",&x,&y);if (x != y && x != y + 2){printf ("No Number\n");continue;}if (x & 1){if (x == y)printf ("%d\n",2 * x - 1);elseprintf ("%d\n",2 * x - 3);}else{if (x == y)printf ("%d\n",2 * x);elseprintf ("%d\n",2 * x - 2);}}return 0;}
0 0
- 【POJ】1663 - Number Steps(找规律)
- HDOJ1393 Number Steps(找规律)
- HDU 1391 Number Steps(思维题目,找规律)
- HDU 1391 Number Steps【找规律】
- HDU 1391 Number Steps(数学题+找规律)
- poj 1663 Number Steps
- POJ 1663 Number Steps
- POJ 1663Number Steps
- POJ 1663 Number Steps
- POJ 1663:Number Steps
- POJ 1663:Number Steps
- ZOJ1414 POJ1663 Number Steps 很简单的找规律题
- uva 846 Steps(找规律)
- poj 1019 Number Sequence 找规律 思维题 ()
- POJ 1663 Number Steps 笔记
- Steps——找规律
- POJ 1068(找规律)
- Codeforces-804 B. Minimum number of steps(贪心+规律)
- MFC学习笔记——消息映射机制afx
- 关于shape
- TortoiseSVN客户端图标覆盖问题
- 文章标题
- ParalleX OS 设计与实现 一致性理念设计
- 【POJ】1663 - Number Steps(找规律)
- swiprefreshlayout主动显示小圆圈
- for each 循环
- 跨平台混合开发
- opencv knn,svm,ann,人脸识别类的使用总结
- IOS代码签名
- 用Calendar实现简单的小日历
- LeetCode:Palindrome Linked List(回文链表)
- Activity之间的数据传递