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: a, x, y, 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.

Example
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

#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
int main()
{int a,y,m,n,k,w;double x;while(~scanf("%d%lf%d",&a,&x,&y)){if(y%a==0)printf("-1\n");else{k=y/a;w=k/2;if(k==0){if(a*0.5-fabs(x)>1e-3)printf("1\n");else printf("-1\n");}else if(k&1){m=1+w*3+1;if(a*0.5-fabs(x)>1e-3)printf("%d\n",m);else printf("-1\n");}else{m=1+w*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);else printf("-1\n");    }}}return 0; } 

Hopscotch(思维)相关推荐

  1. 【转】大牛说|为啥有“编程思维”的人,更容易成功?

    除了少部分的人,大多数人都是在大学阶段才开始接触编程的.但是有很多国家已经开始推行儿童编程教育了! 2014年,英国已经把"编程"列入每所学校的必修课程,这就意味着每位5岁以上的孩 ...

  2. 揭富人与穷人21个不同思维 看富豪如何脱颖而出

    <富人是怎么想的>(How Rich People Think)的作者Steve Siebold曾在近30年里采访世界各地的富豪,看究竟是什么让富豪从普通人中站出来. 他发现这和金钱基本没 ...

  3. 学习,思维三部曲:WHAT、HOW、WHY

    学习技术的三部曲:WHAT HOW WHY 我把学习归类为三个步骤:What.How.Why.经过我对周围同事和朋友的观察,大部分感觉自己技术没有提高的人,都仅仅停留在What阶段.下面我把这三个步骤 ...

  4. Linux架构思维导图

    Linux架构思维导图 GUI(Graphical User Interface,图形用户界面) Linux 学习路径 软件框架 Linux 桌面介绍 FHS:文件系统目录标准 Linux 需要特别注 ...

  5. github 思维导图开元软件_画思维导图记笔记的工具软件

    思维导图是很多人在做笔记的时候都会用到的一种记录方式,使用思维导图可以简单有效的表达发散性思维,能够协助人们在各种因素间平衡展开思考,从而提升自己笔记的含金量和工作效率,有没有画思维导图记笔记的工具软 ...

  6. 大数据概念思维导图_思维导图|数据化风控(信用评分建模教程)

    本文将按<数据化风控--信用评分建模教程>行文逻辑,并结合相关参考材料,为大家梳理本书涉及的重点知识,也算是自己读书笔记分享.有需要的同学可先收藏.点赞,以便回顾学习和吸收,当然,如果愿意 ...

  7. puml绘制思维导图_如何用ProcessOn画出漂亮的思维导图

    说到绘制思维导图,很多人可能都知道XMind,但不一定了解ProcessOnProcessOn - 免费在线作图,实时协作,总以为后者绘制流程图很强大,殊不知其在思维导图方面也有很强大的功能. 好工具 ...

  8. 计算机思维采用抽象和分解,凤凰机器人----什么是计算思维?凤凰机器人的编程课中是如何体现它的?...

    对于生活在科技和智能自动化时代的孩子们来说,理解计算机的思维方式,运用计算思维去解决生活中的问题,被认为和听.说.读.写.算一样,是每个人必备的思维能力.然而,到底什么才是计算思维呢? 计算思维是一种 ...

  9. tp3 普通模式url模式_《终身成长》:三个步骤打造成长型思维模式,普通人也可以成功...

    罗伯特很小是一个聪明的孩子,父母以他为傲,经常夸奖他,对他表达爱.结果他没有考上一个纽约第1名的幼儿园,父母就不像以前那样对他了,不会再经常表达爱,夸奖他,对他就越来越冷淡,他在父母眼里是一个失败者, ...

最新文章

  1. 给妹子讲python-S01E15详解python迭代环境
  2. 合肥php开发培训费用,合肥PHP开发培训之PHP文件基础操作
  3. 春节前后学习实践的技术领域
  4. 举例讲清楚模型树和回归树的区别
  5. 面试必问:用 Java 写一个内存泄漏程序
  6. linux运行tcl脚本语言,Tool Command Language (Tcl)初体验
  7. js中setInterval与setTimeout的区别
  8. delphi mysql 加密_Delphi对Access文件加密
  9. oracle procedure可以执行非常复杂的语句吗,oracle-存储过程(procedure)
  10. 魔兽世界忘记账号角色服务器,魔兽世界里我知道了他的游戏角色名字怎样查到他的战网通行证...
  11. 机器视觉硬件选型相关知识
  12. 编译libfetion时,提示 从 int 到 QString 的转换有歧义
  13. 我的世界服务器客户端制作,《我的世界》宇瑄服务器客户端mod
  14. office 2010 ppt 添加音乐等相关问题
  15. Python BeautifulSoup简介
  16. 测试种类大汇总(45类)
  17. Android推特图片保存路径,如何将twitter的URL内容(tweet,user,comment,…)添加到我的android应用程序...
  18. 读《重构:改善既有代码的设计》的思考
  19. [51MCU] Chapter1:芯片引脚
  20. 联想服务器应用场景,联想服务器承载沈阳地铁三大核心应用

热门文章

  1. 淘宝版本nginx使用纯干货
  2. 阿里云oss对象存储上传照片并返回照片路径
  3. snmp对超过16T的磁盘大小识别不对的解决办法
  4. 云原生时代(六): 机会与思考
  5. 因为荒谬,所以才需要信仰
  6. boost库之正则匹配
  7. electron隐藏默认菜单
  8. 机器学习的最小平方法
  9. c盘html文件能删除吗,c盘什么文件可以删除_c盘很乱不敢删怎么解决
  10. 国际绝对音名标准频率定义(32位无符号整型精度、十二等律体系、A4=440.01000Hz)