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. Oracle 中按条件过滤重复记录

    在数据处理中,经常会遇到类似这样的情况:数据库中存在多条记录,其中某些字段值相同,其他字段值不同.实际的业务需要针对这样的情况,只保留一条数据,其他数据删除.如何做到呢?在sql中有top关键字相对容 ...

  2. java实验7-多线程编程

    1 利用Thread和Runnable创建线程 [实验目的] (1)理解用实现Runnable接口的方法实现多线程. (2)掌握线程优先级的设置. (3)加深对线程状态转换的理解. [实验要求] 要求 ...

  3. JavaScript学习笔记:检测数组方法

    检查数组的方法 很多时候我们需要对JavaScript中数据类型(Function.String.Number.Undefined.Boolean和Object)做判断.在JavaScript中提供了 ...

  4. asp.net服务器向客户端弹出对话框,但不使页面边白板

    1: using System; 2: using System.Collections.Generic; 3: using System.Linq; 4: using System.Web; 5: ...

  5. js获取浏览器滚动条距离顶端的距离

    最近在做项目的时候遇到需要用js获取滚动条距离窗口顶端的距离和js获取浏览器可视化窗口的大小,在这儿做一个整理保存:    一.jQuery获取的相关方法 jquery 获取滚动条高度 获取浏览器显示 ...

  6. String new赋值、直接赋值

    String类是final的.String str = new String("Hello"); //创建了两个对象系统会先创建一个匿名对象"Hello"存入堆 ...

  7. 1 Intellij IDEA 个人常用快捷方式

    个人常用快捷方式 alt+enter    万能键                                          inn if(xxx!=null) iter foreach ct ...

  8. asp.net FileUpload 控件上传文件 以二进制的形式存入数据库并将图片显示出来

    图片上传事件代码如下所示: byte[] binary = upload.FileBytes; StringBuilder sqlStrSb = new StringBuilder(); sqlStr ...

  9. LUA 捕获模式 URL编码的例子解析

    function escape(s) s=string.gsub(s,"([&=+%c])",function(c) return string.format(" ...

  10. ionic2+angular2

    ionic2+angular2中踩的那些坑 好久没写什么东西了,最近在做一个ionic2的小东西,遇到了不少问题,也记录一下,避免后来的同学走弯路. 之前写过一篇使用VS2015开发ionic1的文章 ...