CodeForces - 141B Hopscotch (模拟)水
来源:互联网 发布:禁止软件安装的软件 编辑:程序博客网 时间:2024/06/05 11:38
Description
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.
Input
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.
Output
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.
Sample Input
1 0 0
-1
3 1 1
1
3 0 10
5
3 0 7
-1
3 4 0
-1
Sample Output
Hint
Source
#include<stdio.h>#include<string.h>#include<math.h>#include<algorithm>#include<iostream>using namespace std;int main(){int a,y;double x;int n,m;while(scanf("%d%lf%d",&a,&x,&y)!=EOF){if(y%a==0)printf("-1\n");else{int k=y/a;int kk=k/2;if(k==0){if(a*0.5-fabs(x)>1e-3)printf("1\n");elseprintf("-1\n");}else if(k&1){m=1+kk*3+1;if(a*0.5-fabs(x)>1e-3)printf("%d\n",m);elseprintf("-1\n");}else{m=1+kk*3;if(x<0&&a*1.0-fabs(x)>1e-3)printf("%d\n",m-1);else if(x>0&&a*1.0-fabs(x)>1e-3)printf("%d\n",m);elseprintf("-1\n");}}}return 0;}
- CodeForces - 141B Hopscotch (模拟)水
- CodeForces 141B - Hopscotch
- CodeForces 141B Hopscotch
- codeforces 141-B. Hopscotch(数学)
- CodeForces 141B Hopscotch(分类讨论)
- 【Codeforces 141 B Hopscotch 】+ 构造
- codeforces 141 B. Hopscotch (规律)
- Codeforces Round #101 (Div. 2) B. Hopscotch
- CodeForces 754B(模拟)
- codeforces 839B(模拟)
- CodeForces - 659B Qualifying Contest (模拟)水
- Codeforces--616B--Dinner with Emma(模拟水题)
- CodeForces - 616B Dinner with Emma (模拟)水
- CodeForces - 660B Seating On Bus (模拟)水
- CodeForces - 554B Ohana Cleans Up (模拟)水
- CodeForces - 246B Increase and Decrease (模拟)水
- CodeForces - 670B Game of Robots (模拟)水
- CodeForces - 673B Problems for Round (模拟)水
- PHY芯片 AR8033 学习笔记
- Java 8 学习指南
- Servlet01
- ElasticSearch(三)--文档
- SIFT特征提取分析
- CodeForces - 141B Hopscotch (模拟)水
- 80端口被(Pid=4)占用的解决方法
- [PB]-数据窗口对象(一)
- matplotlib处理科学计算数据-L1
- hdu4614 Vases and Flowers(线段树+二分)
- JS canvas 表情
- 面向对象的一些心得
- eclipse中server中无法加载tomcat了
- 输出乘法口诀表