Number Steps


Time Limit: 2 Seconds      Memory Limit: 65536 KB


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<iostream>
using namespace std;
int main()
{
int n;
cin>>n;
while(n--)
{
int a,b;
cin>>a>>b;
if(a==b||a-b==2)
{
if(a==b)
{
if(a&1)cout<<2*a-1<<endl;
else cout<<2*a<<endl;
}
else
{
if(b&1)cout<<2*a-3<<endl;
else cout<<2*a-2<<endl;
}
}
else cout<<"No Number"<<endl;
}
return 0;
}

ZOJ 1414:Number Steps的更多相关文章

  1. ZOJ 2850和ZOJ 1414

    下午上数据结构,结果竟然没有新题.T T果断上OJ来水一发 ZOJ 2850   Beautiful Meadow 传送门http://acm.zju.edu.cn/onlinejudge/showP ...

  2. HDU-1391 Number Steps

    http://acm.hdu.edu.cn/showproblem.php?pid=1391 Number Steps Time Limit: 2000/1000 MS (Java/Others)   ...

  3. Number Steps

    Number Steps Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Tota ...

  4. POJ 1663:Number Steps

    Number Steps Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 13758   Accepted: 7430 Des ...

  5. POJ 1663:Number Steps

    Number Steps Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 13664   Accepted: 7378 Des ...

  6. ZOJ 3908 Number Game ZOJ Monthly, October 2015 - F

    Number Game Time Limit: 2 Seconds      Memory Limit: 65536 KB The bored Bob is playing a number game ...

  7. [ZOJ 2836] Number Puzzle

    Number Puzzle Time Limit: 2 Seconds      Memory Limit: 65536 KB Given a list of integers (A1, A2, .. ...

  8. HDOJ 1391 Number Steps(打表DP)

    Problem Description Starting from point (0,0) on a plane, we have written all non-negative integers ...

  9. hdu1391(Number Steps )

    Problem Description Starting from point (0,0) on a plane, we have written all non-negative integers ...

随机推荐

  1. dva使用及项目搭建

    一.简介 本文将简单分析dva脚手架的使用及项目搭建过程. 首先,dva是一个基于redux和redux-saga的数据流方案,然后为了简化开发体验,dva还额外内置了react-router和fet ...

  2. servlet页面没有跳转

    Boolean b = userService.selectByParams(user);if (b) { req.getSession().setAttribute("loginname& ...

  3. CodeForcesGym 100517H Hentium Scheduling

    Hentium Scheduling Time Limit: 2000ms Memory Limit: 262144KB This problem will be judged on CodeForc ...

  4. oracle10g_v$sqltext之对等视图v$sqltext_with_newlines

    --v$sqltext_with_newlines是v$sqltext等同体,较之易读性强(由sql_address及sql_hash_value唯一确认一个cached cursor中的sql)SQ ...

  5. HDU 1016 素数环问题

    题目大意: 给定1-n这n个数,组成以1开头的素数环,保证相邻两个数相加均为素数 题目用dfs搜索再回溯,这样碰到不成立的立刻退出递归,就减少了很多步骤,不然暴力来就是n!次复杂度,肯定是超时的 每次 ...

  6. hdu 4788

    #include<stdio.h> #include<math.h> int main() { int a; double d; char s],ch; for;i++) d; ...

  7. springMVC @Value的使用

    @Value 功能:将一个SpEL(SpEL:spring表达式类似于ognl)表达式结果映射到功能处理方法的参数上 例子:获取系统参数'java.vm.version'的值给到变量jvmVersio ...

  8. ***XAMPP:报错 Unable to load dynamic library的解决方法

    A PHP Error was encountered Severity: Core Warning Message: PHP Startup: Unable to load dynamic libr ...

  9. 创建Django项目(二)——数据库配置

    2013-08-05 20:53:44|          1.数据库配置         举例是用MySQL数据库,首先在settings文件中做配置,如下: DATABASES = {     ' ...

  10. node+mongodb+win7

    一.安装mongodb,参照教程,注意要先启动mongod.exe,再启动mongd.exe.