Hopscotch

Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u

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 length a.

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: axy, where a (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

Input
1 0 0
Output
-1
Input
3 1 1
Output
1
Input
3 0 10
Output
5
Input
3 0 7
Output
-1
Input
3 4 0
Output
-1
题解:一个石子在如图形状里面的区域,在边界或者不在图形内部输出-1;注意边界的考虑;输出三个数代表正方形变长,以及石子坐标;
代码:
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<stack>
#include<set>
using namespace std; int main(){
int a, x, y;
while(~scanf("%d%d%d", &a, &x, &y)){
double cx = 1.0 * x /a, cy = 1.0 * y/a;
int t = (int)(cy + 0.999999999999999);
if(y % a == ){
puts("-1");
continue;
}
if(y == ){
puts("-1");
continue;
}
if(t == || t == ){
if(fabs(cx) >= 0.5)
puts("-1");
else
printf("%d\n", t);
continue;
}
// printf("t = %d\n", t);
if(t % == ){
if(fabs(cx) >= 0.5){
puts("-1");
}
else
printf("%d\n", t + t/ - );
}
else{
if(fabs(cx) >= || x == ){
puts("-1");
}
else{
if(cx < )
printf("%d\n", (t - ) + (t - )/);
else
printf("%d\n", (t - ) + (t - )/ + );
}
}
}
return ;
}

Hopscotch(细节)的更多相关文章

  1. River Hopscotch POJ - 3258

    Every year the cows hold an event featuring a peculiar version of hopscotch that involves carefully ...

  2. 【洛谷】2990:[USACO10OPEN]牛跳房子Cow Hopscotch【单调队列优化DP】

    P2990 [USACO10OPEN]牛跳房子Cow Hopscotch 题目描述 The cows have reverted to their childhood and are playing ...

  3. Vue.js 和 MVVM 小细节

    MVVM 是Model-View-ViewModel 的缩写,它是一种基于前端开发的架构模式,其核心是提供对View 和 ViewModel 的双向数据绑定,这使得ViewModel 的状态改变可以自 ...

  4. vue2.0实践的一些细节

    最近用vue2.0做了个活动.做完了回头发现,好像并没有太多的技术难点,而自己好像又做了比较久...只能说效率有待提升啊...简单总结了一些比较细节的点. 1.对于一些已知肯定会有数据的模块,先用一个 ...

  5. 深入理解JS 执行细节

    javascript从定义到执行,JS引擎在实现层做了很多初始化工作,因此在学习JS引擎工作机制之前,我们需要引入几个相关的概念:执行环境栈.全局对象.执行环境.变量对象.活动对象.作用域和作用域链等 ...

  6. javaScript中的小细节-script标签中的预解析

    首先介绍预解析,虽然预解析字面意思很好理解,但是却是出坑出的最多的地方,也是bug经常会有的地方,利用好预解析的特性可以解决很多问题,并且提高代码的质量及数量,浏览器在解析代码前会把变量的声明和函数( ...

  7. 分享MSSQL、MySql、Oracle的大数据批量导入方法及编程手法细节

    1:MSSQL SQL语法篇: BULK INSERT [ database_name . [ schema_name ] . | schema_name . ] [ table_name | vie ...

  8. Android ScrollView监听滑动到顶部和底部的两种方式(你可能不知道的细节)

    Android ScrollView监听滑动到顶部和底部,虽然网上很多资料都有说,但是不全,而且有些细节没说清楚 使用场景: 1. 做一些复杂动画的时候,需要动态判断当前的ScrollView是否滚动 ...

  9. [更新设计]跨平台物联网通讯框架ServerSuperIO 2.0 ,功能、BUG、细节说明,以及升级思考过程!

    注:ServerSuperIO 2.0 还没有提交到开源社区,在内部测试!!! 1. ServerSuperIO(SSIO)说明 SSIO是基于早期工业现场300波特率通讯传输应用场景发展.演化而来. ...

随机推荐

  1. _js day9

  2. html的空格显示距离问题

    一.使用全角空格 全角空格被解释为汉字,所以不会被被解释为HTML分隔符,可以按照实际的空格数显示. 二.使用空格的替代符号 替代符号就是在需要显示空格的地方加入替代符号,这些符号会被浏览器解释为空格 ...

  3. ControlStyles(枚举)

    指定控件的样式和行为. 此枚举有一个 FlagsAttribute 特性,通过该特性可使其成员值按位组合.属性: ContainerControl:如果为true,则控件是类似容器的控件. UserP ...

  4. Windows命令行(DOS命令)教程-6 (转载)http://arch.pconline.com.cn//pcedu/rookie/basic/10111/15325_5.html

    8. type [功能] 在屏幕上显示文本文件内容命令 [格式] type [C:][path]filename.ext [说明] type命令用来在屏幕上快速.简便地显示文本文件的内容,扩展名为TX ...

  5. c#鼠标在控件上面,然后显示文字

    先添加toolTip控件到界面 然后每个控件的属性会多一项 ToolTip 第一种:直接给里面加文字 第二种: private void pictureBox_topmost_MouseHover(o ...

  6. ​C语言数组作为函数参数

    数组可以作为函数的参数使用,进行数据传送. 数组用作函数参数有两种形式,一种是把数组元素(下标变量)作为实参使用:另一种是把数组名作为函数的形参和实参使用. 数组元素作函数实参 数组元素就是下标变量, ...

  7. [0] Tornado Todo 开篇

    参考自: python: tornado例子 Github地址:tornado_todo 开发环境: Python包的安装: 首先安装 pip: sudo apt-get install python ...

  8. 1172: 单词接龙(XCOJ 暴力DFS)

    1172: 单词接龙 时间限制: 1 Sec  内存限制: 128 MB提交: 12  解决: 5 标签提交统计讨论版 题目描述 单词接龙是一个与我们经常玩的成语接龙相类似的游戏,现在我们已知一组单词 ...

  9. 使用Hexo搭建GitPage

    资料: hexo官方文档:https://hexo.io/zh-cn/docs/ jekyll官方文档:http://jekyll.com.cn/docs/home/ 简介: 使用hexo和jekyl ...

  10. 开源日志系统 log4c 使用心得+总结

    http://blog.csdn.net/sky_qing/article/details/7208645 一.安装: 我看网上好多人介绍log4c安装的时候都说有两个步骤:先下载expat安装包并安 ...