CF141B.Hopscotch

普及/提高-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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.

冬天已将近过半,玛丽亚开始憧憬夏天。她厌倦了滑冰鞋和雪橇,整晚都在梦到跳房子游戏。这是一种非常流行的儿童游戏。游戏场地(即游戏场)如图所示(所有方块均为正方形,从下往上编号,同一行内的方块从左往右编号)。我们用一串数字来描述该跳房子游戏的布局,这些数字表示各行中方块的数量,从最底层开始:1-1-2-1-2-1-2-(1-2)...,此后周期性重复“(1-2)”。

坐标系定义如图所示。所有正方形的边长均相等,长度为 aa。

玛丽亚是一位非常聪明伶俐的女孩,她关注着一个相当严肃的问题:若她将石子投向坐标为 (x, y)(x,\,y) 的点,石子是否会落入某个正方形内?若答案为是,则还需确定该正方形的编号。

我们认为:仅当石子严格位于某正方形内部时,才视为击中该正方形。换言之,落在正方形边界的石子不被视为击中任何正方形。

输入格式

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.

唯一的一行输入包含三个整数:aa、xx、yy,其中 aa(1 ≤ a ≤ 1001 \le a \le 100)为正方形的边长,xx 和 yy(−106 ≤ x ≤ 106-10^6 \le x \le 10^6,0 ≤ y ≤ 1060 \le y \le 10^6)为石头的坐标。

输出格式

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(不带引号)。

输入输出样例

  • 输入#1

    1 0 0

    输出#1

    -1
  • 输入#2

    3 1 1

    输出#2

    1
  • 输入#3

    3 0 10

    输出#3

    5
  • 输入#4

    3 0 7

    输出#4

    -1
  • 输入#5

    3 4 0

    输出#5

    -1

输入解题思路,AI测评打分。不知道怎么写?

首页