A8273 | Hopscotch
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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.
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.
输入格式
The only input line contains three integers: $a$ , $x$ , $y$ , where $a$ ( $1<=a<=100$ ) is the side of the square, $x$ and $y$ ( $-10^{6}<=x<=10^{6},0<=y<=10^{6}$ ) are coordinates of the stone.
输出格式
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 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
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted