* Hopscotch
来源:互联网 发布:ubuntu wine qq2016 编辑:程序博客网 时间:2024/05/01 13:04
So nearly half of the winter is over and Maria is dreaming about summer. She's fed up with skates and sleds, she was dreaming about Hopscotch all night long. It's a very popular children's game. The game field, the court, looks as is shown in the figure (all blocks are square and are numbered from bottom to top, blocks in the same row are numbered from left to right). Let us describe the hopscotch with numbers that denote the number of squares in the row, staring from the lowest one: 1-1-2-1-2-1-2-(1-2)..., where then the period is repeated (1-2).
The coordinate system is defined as shown in the figure. Side of all the squares are equal and have lengtha.
Maria is a very smart and clever girl, and she is concerned with quite serious issues: if she throws a stone into a point with coordinates(x, y), then will she hit some square? If the answer is positive, you are also required to determine the number of the square.
It is believed that the stone has fallen into the square if it is located strictly inside it. In other words a stone that has fallen on the square border is not considered a to hit a square.
The only input line contains three integers: a,x, y, wherea (1 ≤ a ≤ 100) is the side of the square,x and y ( - 106 ≤ x ≤ 106, 0 ≤ y ≤ 106) are coordinates of the stone.
Print the number of the square, inside which the stone fell. If the stone is on a border of some stone or outside the court, print "-1" without the quotes.
1 0 0
-1
3 1 1
1
3 0 10
5
3 0 7
-1
3 4 0
-1
还以为就图中显示的几个方框,原来上面不断循环出现,除去第一个,3个为一组不断循环
code:
#include<cstdio>#include<cmath>using namespace std;int main(){ int a,x,y; scanf("%d %d %d",&a,&x,&y); double b = a* 1.0/2; if(y<=a&&abs(x)>=b|| y%a== 0||(x==0&&y==0)) printf("-1\n"); else if(y<=a&&abs(x)<b) printf("1\n"); else{ y =y/a; if(y%2!= 0){//奇数个a if(abs(x)>=b) printf("-1\n"); else printf("%d\n",y/2*3+2); } else{ if(abs(x)>=a||x==0) printf("-1\n"); else if(x<0) printf("%d\n",y/2*3); else printf("%d\n",y/2*3+1); } } return 0;}
- Hopscotch
- Hopscotch
- Hopscotch
- * Hopscotch
- Hopscotch
- Hopscotch
- Hopscotch
- POJ3050 Hopscotch
- POJ3258River Hopscotch
- POJ3050--Hopscotch
- River Hopscotch
- POJ3050-Hopscotch
- River Hopscotch
- Hopscotch POJ3050
- River Hopscotch
- River Hopscotch
- poj3258River Hopscotch
- POJ3050 Hopscotch
- shell if test
- 博客转移
- AngularJS—理解AngularMVC模式
- Web服务请求异步化介绍
- 数据结构实验之查找七:线性之哈希表
- * Hopscotch
- HBase之基础理解
- Hadoop中基于文件的数据格式(1)SequenceFile
- 2016年第六届ACM趣味编程循环赛 Round #1 B题
- Spring AOP 配置文件的简单理解
- 编译MeshLab(3)—VS2010编译MeshLab源码之编译meshlab_mini.pro
- JavaWeb ( HttpServletRequest,HttpServletResponse)
- 【设计模式 - 22】之策略模式(Strategy)
- JAVA 中 List Set 总结