Number Steps

时间:2022-09-13 22:44:21

Number Steps

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 4482    Accepted Submission(s):
2732

Problem 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.

Number Steps

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
 #include <iostream>
#include <cstdio>
using namespace std;
int main()
{
int x,y;
int T;
cin>>T;
while(T--)
{
cin>>x>>y;
if(x-y==||x-y==)
{
if(x-y==)
{
if(x%==)
cout<<*x<<endl;
else
cout<<*x-<<endl;
}
else
{
if(x%==)
cout<<x+y<<endl;
else
cout<<x+y-<<endl;
}
}
else
printf("No Number\n");
}
}

Number Steps的更多相关文章

  1. HDU-1391 Number Steps

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

  2. ZOJ 1414&colon;Number Steps

    Number Steps Time Limit: 2 Seconds      Memory Limit: 65536 KB Starting from point (0,0) on a plane, ...

  3. POJ 1663&colon;Number Steps

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

  4. POJ 1663:Number Steps

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

  5. HDOJ 1391 Number Steps&lpar;打表DP&rpar;

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

  6. hdu1391&lpar;Number Steps &rpar;

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

  7. HDU 1391 number steps(找规律,数学)

    Starting from point (0,0) on a plane, we have written all non-negative integers 0, 1, 2,... as shown ...

  8. 九度OJ 1136:Number Steps(步数) (基础题)

    时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:691 解决:412 题目描述: Starting from point (0,0) on a plane, we have written ...

  9. hdu 1391 Number Steps(规律)

    题意:找规律 思路:找规律 #include<iostream> #include<stdio.h> using namespace std; int main(){ int ...

随机推荐

  1. 安装oracle数据库,登录 时无法连接目标机

    oracle11g 在dos命令里输入输入sqlplus 输入如用户名: 输入口令: 还是无法连接 解决办法: 输入sqlplus/nolog按enter键再输入conn/as sysdba就好了

  2. boneCP原理研究

    ** 转载请注明源链接:http://www.cnblogs.com/wingsless/p/6188659.html boneCP是一款关注高性能的数据库连接池产品 github主页 . 不过最近作 ...

  3. NYOJ-228 士兵杀敌5

    士兵杀敌(五) 时间限制:2000 ms  |  内存限制:65535 KB 难度:5 描述 南将军麾下有百万精兵,现已知共有M个士兵,编号为0~M,每次有任务的时候,总会有一批编号连在一起人请战(编 ...

  4. Linux---More命令 初级实现

    Linux: more已实现:more filename , quit不需要回车未实现:command | more 重定向 ,显示百分比 Waiting... /* Linux: more 已实现: ...

  5. mysql slave 错误解决

    执行CHANGE MASTER TO master_host............后报错 ERROR 1201 (HY000): Could not initialize master info s ...

  6. xrange和range区别

    range和xrange这两个函数基本都是在循环的时候使用的. >>> for x in range(10,21,1): ... print x ... 10 11 12 13 14 ...

  7. javaweb项目的优化 - 几番思念

    简单地来看一个浏览器用户访问的流程: 浏览器->服务器->返回结果显示  这么简单地看,可能想得到的优化手段很少,常见的可能就是优化sql,加快数据库处理:加个缓存,加快返回:使用静态文件 ...

  8. List实现

    1.元素添加 #include <stdio.h> #include <stdlib.h> struct ListNode{ struct ListNode* next; in ...

  9. kotlin 委托

    委托模式是软件设计模式中的一项基本技巧.在委托模式中,有两个对象参与处理同一个请求,接受请求的对象将请求委托给另一个对象来处理. Kotlin 直接支持委托模式,更加优雅,简洁.Kotlin 通过关键 ...

  10. Python threading&lpar;多线程&rpar;

    threading模块在较低级别thread模块之上构建更高级别的线程接口. 一.threading模块定义了以下函数和对象: threading.active_count() 等同于threadin ...