HDU 1391 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.
InputThe 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.
OutputFor 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<stdio.h>
#include<algorithm>
using namespace std;
int main()
{
int t;
int x,y;
scanf("%d",&t);
while(t--)
{
scanf("%d%d",&x,&y);
if(x==y+2||x==y)//2条线所在
{
if(x%2==1)//分奇偶找规律
printf("%d\n",(x+y)-1);
else if(x%2==0)
printf("%d\n",x+y);
}
else
printf("No Number\n");
}
return 0;
}
HDU 1391 number steps(找规律,数学)的更多相关文章
- hdu 1391 Number Steps(规律)
题意:找规律 思路:找规律 #include<iostream> #include<stdio.h> using namespace std; int main(){ int ...
- HDU 4279 Number(找规律)
Number Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Sub ...
- hdu 4952 Number Transformation (找规律)
题目链接 题意:给你个x,k次操作,对于第i次操作是:要找个nx,使得nx是>=x的最小值,且能整除i,求k次操作后的数 分析: 经过打表找规律,会发现最后的x/i,这个倍数会趋于一个固定的值, ...
- HDU 4861 Couple doubi(找规律|费马定理)
Couple doubi Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Submit ...
- hdu 5241 Friends(找规律?)
Friends Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)Total S ...
- hdu 2604 Queuing dp找规律 然后矩阵快速幂。坑!!
http://acm.hdu.edu.cn/showproblem.php?pid=2604 这题居然O(9 * L)的dp过不了,TLE, 更重要的是找出规律后,O(n)递推也过不了,TLE,一定 ...
- hdu 3951 - Coin Game(找规律)
这道题是有规律的博弈题目,,, 所以我们只需要找出规律来就ok了 牛人用sg函数暴力找规律,菜鸟手工模拟以求规律...[牢骚] if(m>=2) { if(n<=m) {first第一口就 ...
- LightOj 1245 --- Harmonic Number (II)找规律
题目链接:http://lightoj.com/volume_showproblem.php?problem=1245 题意就是求 n/i (1<=i<=n) 的取整的和这就是到找规律的题 ...
- HDU 5703 Desert (找规律)
题意:一杯水有n的容量,问有多少种方法可以喝完. 析:找规律,找出前几个就发现规律了,就是2的多少次幂. 代码如下: #include <cstdio> #include <stri ...
随机推荐
- Hadoop Yarn on Docker
搭建Hadoop Yarn on Docker 一.概览 Docker基于Linux Container技术整合了一堆易用的接口用于构建非常轻量级的虚拟机.Docker Container Execu ...
- 2018宁夏邀请赛K Vertex Covers
题目链接:https://nanti.jisuanke.com/t/28411 题意: 给出n(n<=36)个点的一个图.求点覆盖集数. 题解: 将n个点折半为L和R两部分.对于R内部的边,枚举 ...
- BZOJ1558 [JSOI2009]等差数列 【线段树】
题目链接 BZOJ1558 题解 等差数列,当然是差分一下 差分值相同的连续位置形成等差数列,我们所选的两个等差数列之间可以有一个位置舍弃 例如: \(1 \; 2 \; 3 \; 6 \; 8 \; ...
- JS格式化时间(支持小程序,兼容IOS)
})-(\d{})-(\d{})T(\d{}):(\d{}):(\d{})/ /** * @function format time * @param val, format * @return {s ...
- Spring事务只对运行时异常回滚
我们在使用Spring时候一般都知道事务在遇到异常的时候会回滚,岂不知Spring的事务默认只有在发生运行时异常即:RunTimeException时才会发生事务,如果一个方法抛出Exception或 ...
- linux 端口号、进程id、杀进程、查询tcp的连接(各种状态的)
sudo netstat -antupkill -s 9 50713netstat -n | grep 61616netstat -n | awk '/^tcp/ {++S[$NF]} END {fo ...
- postfix导致maillog填满磁盘空间的巨坑!
双休日回家pull在公司修改的代码...于是菜鸟的linux探索之路开始了 1.df -f发现磁盘又占满了(之前是node的error) 2.发现maillog整整10个G,无数条(Jul 7 04: ...
- java属性为什么没多态,而是方法多态
定义 java多肽的特性:方法具有多态性,属性却没有. 准备 基类: 子类: 测试类: 结果: 分析如下 父类 a=new 子类,实际对象时子类.由于向上转型,我们可以用父类在编译期间代替子类,使得编 ...
- Linux基础(1)
一.Linux的安装及相关配置 1.VMware Workstation安装CentOS7.0 图文版 详细步骤可以看连接:http://blog.csdn.net/alex_my/article/d ...
- CDLinux 自动休眠功能的关闭方法
CDLinux 自动休眠功能的关闭方法: 控制台下使用xset命令来完成. xset q 可以查看当前屏幕保护和电源管理的状态信息 具体设置时,常用的有以下参数: xset s //这个参数设置屏 ...