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 ...
随机推荐
- TCP/IP Note3
TCP/IP协议 TCP/IP是不同的通信协议的大集合. 协议族:TCP/IP是基于TCP和IP这两个最初的协议之上的不同的通信协议的大集合. 1. TCP - 传输控制协议 TCP用于从应用程序到网 ...
- Linux SNMP 监控一些常用OID
Linux SNMP 监控一些常用OID ===============linux服务器snmp常用oid http://www.haiyun.me/archives/linux-snmp-oid.h ...
- 判断当前系统当前浏览器是否安装启用 Adobe Flash Player,检查在chrome中的状态
一.判断当前所在系统 let sUserAgent = navigator.userAgent;let isWin = (navigator.platform == "Win32" ...
- net.sf.json与fastjson两种jar包的使用
首先说清楚:这两种方式是进行json解析的两种不同的方式而已,哪一种都可以. 一.引入net.sf.json包 首先用net.sf.json包,当然你要导入很多包来支持commons-beanutil ...
- Bash 实例,第一部分
您可能要问:为什么要学习 Bash 编程?好,以下是几条令人信服的理由: 已经在运行它 如果查看一下,可能会发现:您现在正在运行 bash.因为 bash 是标准 Linux shell,并用于各种目 ...
- border-image
一.border-image的兼容性 border-image可以说是CSS3中的一员大将,将来一定会大放光彩,其应用潜力真的是非常的惊人.可惜目前支持的浏览器有限,仅 Firefox3.5,chro ...
- WebKit阅读起步
转摘自:http://my.oschina.net/myemptybottle/blog/42683 部分转摘,全文请查看原文! 我第一次看到WebKit代码中did,will前缀有点困惑,看多了才熟 ...
- lucene、solr、nutch三者的关系
lucene是一个做搜索用的类库. nutch和solr都是基于lucene的,二者都是可直接运行的应用程序: 直接在业务上使用lucene的倒是不太多见. solr主要提供了建立索引(用户可以直接p ...
- Spring - IoC(2): 属性注入 & 构造注入
依赖注入是指程序运行过程中,如果需要另外的对象协作(访问它的属性或调用它的方法)时,无须在代码中创建被调用者,而是依赖于外部容器的注入. 属性注入(Setter Injection) 属性注入是指 I ...
- finally return 执行顺序问题
网上有很多人探讨Java中异常捕获机制try...catch...finally块中的finally语句是不是一定会被执行?很多人都说不是,当然他们的回答是正确的,经过我试验,至少有两种情况下fina ...