九度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. ...
 
随机推荐
- net9:图片文件转换成二进制流存入SQL数据库,以及从数据库中读取二进制流输出文件
			
原文发布时间为:2008-08-10 -- 来源于本人的百度文章 [由搬家工具导入] using System;using System.Data;using System.Configuration ...
 - 回顾scroll
			
<!doctype html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
 - noip 2010 关押罪犯 二分答案+二分图染色 || 并查集
			
题目链接 题目描述 S 城现有两座监狱,一共关押着N 名罪犯,编号分别为1~N.他们之间的关系自然也极不和谐.很多罪犯之间甚至积怨已久,如果客观条件具备则随时可能爆发冲突.我们用"怨气值&q ...
 - 关于nginx所遇问题
			
1. 如果出现 nginx: [error] invalid PID number “” in “/usr/local/var/run/nginx/nginx.pid” 错误重新加载配置文件 /usr ...
 - hdu 4503(数学,概率)
			
湫湫系列故事——植树节 Time Limit: 1000/500 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others)Total ...
 - 美图秀秀web开发文档
			
Xiuxiu 组件 import React, { Component } from 'react'; class XiuXiu extends Component { componentDidMou ...
 - 转载——Step by Step 创建一个 Web Service
			
原创地址:http://www.cnblogs.com/jfzhu/p/4022139.html 转载请注明出处 (一)创建Web Service 创建第一个项目,类型选择ASP.NET Empty ...
 - UICollectionView的cell创建直接从第三个数据开始问题
			
实现的效果是这样 大概意思就是第一组没有数据就直接将改组的cell高度变成0效果实现了,但是第二组数据创建cell就出问题了--奇葩问题 * 代码问题在这```-(CGSize)collectionV ...
 - ASP.NET HttpContext类
			
IHttpHandler 接口 定义 ASP.NET 以异步方式处理使用自定义 HTTP 处理程序的 HTTP Web 请求而实现的协定 封装http请求信息 HttpContext.Curren ...
 - vs2017秘钥
			
VS2017专业版和企业版激活密钥 需要的请自取- Enterprise: NJVYC-BMHX2-G77MM-4XJMR-6Q8QF Professional: KBJFW-NXHK6-W4WJM- ...