九度OJ 1136:Number Steps(步数) (基础题)
时间限制:1 秒
内存限制:32 兆
特殊判题:否
提交:691
解决:412
- 题目描述:
-
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.
- 样例输入:
-
3
4 2
6 6
3 4
- 样例输出:
-
6
12
No Number
思路:
细节题,要分清各类情况。
代码:
#include <stdio.h> int main(void)
{
int n, i;
int x, y; while (scanf("%d", &n) != EOF)
{
for(i=0; i<n; i++)
{
scanf("%d%d", &x, &y);
if (x == y || x-y == 2)
{
if (x%2 == 0)
printf("%d\n", x+y);
else
printf("%d\n", x+y-1);
}
else
printf("No Number\n");
}
} return 0;
}
/**************************************************************
Problem: 1136
User: liangrx06
Language: C
Result: Accepted
Time:20 ms
Memory:912 kb
****************************************************************/
九度OJ 1136:Number Steps(步数) (基础题)的更多相关文章
- 九度OJ 1197:奇偶校验 (基础题)
时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:3590 解决:1511 题目描述: 输入一个字符串,然后对每个字符进行奇校验,最后输出校验后的二进制数(如'3',输出:10110011). ...
- 九度OJ 1059:abc (基础题)
时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:3642 解决:2869 题目描述: 设a.b.c均是0到9之间的数字,abc.bcc是两个三位数,且有:abc+bcc=532.求满足条件的 ...
- 九度OJ 1057:众数 (基础题)
时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:8431 解决:2819 题目描述: 输入20个数,每个数都在1-10之间,求1-10中的众数(众数就是出现次数最多的数,如果存在一样多次数的 ...
- 九度OJ 1032:ZOJ (基础题)
时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:4569 解决:2561 题目描述: 读入一个字符串,字符串中包含ZOJ三个字符,个数不一定相等,按ZOJ的顺序输出,当某个字符用完时,剩下的 ...
- 九度OJ 1116:加减乘除 (基础题)
时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:1466 解决:902 题目描述: 根据输入的运算符对输入的整数进行简单的整数运算. 运算符只会是加+.减-.乘*.除/.求余%.阶乘!六个运 ...
- 九度OJ 1006 ZOJ问题 (这题測试数据有问题)
题目1006:ZOJ问题 时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:15725 解决:2647 题目描写叙述: 对给定的字符串(仅仅包括'z','o','j'三种字符),推断他能否AC ...
- 九度oj 1003
前几天开刷九度oj,准备把做的题都放上,先放1003 题目1003:A+B 时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:16923 解决:7029 题目描述: 给 ...
- 【九度OJ】题目1040:Prime Number 解题报告
[九度OJ]题目1040:Prime Number 解题报告 标签(空格分隔): 九度OJ 原题地址:http://ac.jobdu.com/problem.php?pid=1040 题目描述: Ou ...
- 九度OJ,题目1089:数字反转
题目描述: 12翻一下是21,34翻一下是43,12+34是46,46翻一下是64,现在又任意两个正整数,问他们两个数反转的和是否等于两个数的和的反转. 输入: 第一行一个正整数表示测试数据的个数n. ...
随机推荐
- 模仿手机qq空间头部向上滚动颜色加深
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- HDU 6218 (线段树+set)
HDU 6218 Bridge Problem : 给一个2×n的矩阵,一开始矩阵所有相邻点之间有一条边.有其.个询问,每次给出两个相邻的点的坐标,将其中的边删除或者添加,问如此操作之后整张图的割边数 ...
- 使用gcc的-finstrument-functions选项进行函数跟踪【转】
转自:http://blog.csdn.net/jasonchen_gbd/article/details/44044899 版权声明:本文为博主原创文章,转载请附上原博链接. GCC Functio ...
- hdu 5437(优先队列模拟)
Alisha’s Party Time Limit: 3000/2000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others) ...
- Pollard_rho定理 大数的因数个数 这个板子超级快
https://nanti.jisuanke.com/t/A1413 AC代码 #include <cstdio> #include <cstring> #include &l ...
- Codeforces 597B Restaurant(离散化 + 贪心)
题目链接 Restaurant 题目意思就是在$n$个区间内选出尽可能多的区间,使得这些区间互不相交. 我们先对这$n$个区间去重. 假如有两个区间$[l1, r1],[l2, r2]$ 若满足$l1 ...
- Codeforces 375D Tree and Queries(DFS序+莫队+树状数组)
题目链接 Tree and Queries 题目大意 给出一棵树和每个节点的颜色.每次询问$vj, kj$ 你需要回答在以$vj$为根的子树中满足条件的的颜色数目, 条件:具有该颜色的节点数量至少 ...
- Codeforces 490F Treeland Tour(离散化 + 线段树合并)
题目链接 Treeland Tour 题目就是让你求树上LIS 先离散化,然后再线段树上操作.一些细节需要注意一下. #include <bits/stdc++.h> using name ...
- rostopic pub
rostopic pub -1 reinit_motor_wheel std_msgs/String -- "reinit_motor_wheel"rostopic pub -r ...
- Xamarin.Forms特殊的视图BoxView
Xamarin.Forms特殊的视图BoxView BoxView是Xamarin.Forms比较特殊的视图.该视图构建非常简单,其作用也很单一.它的作用就是构成一个特定颜色的色块.在界面设计中, ...