QOJ.ac

QOJ

حد الوقت: 1 s حد الذاكرة: 256 MB مجموع النقاط: 100

#9000. 小机器人 Robby

الإحصائيات

考虑一个具有正交坐标系的平面。有一个可编程机器人,简称 Robby,位于该平面的点 $(0, 0)$ 处,初始朝向为北,即第二坐标增加的方向。

对 Robby 进行编程,即给予它一个(数值)指令序列 $d_1, d_2, \dots, d_n$。一旦 Robby 启动,它将执行以下移动:第 $i$ 次移动(对于 $i \ge 1$)包括向前移动 $d_{(i-1) \pmod n + 1}$ 个单位(其中 “$\text{mod } n$” 表示整数除法的余数),随后进行 $90^\circ$ 的顺时针转向。

Robby 配备的电池可使其精确运行 $t$ 秒。向前移动一个单位和进行 $90^\circ$ 顺时针转向各耗时一秒。

编写一个程序,计算在电池耗尽之前,Robby 会经过给定点 $(x, y)$ 多少次。

输入格式

第一行包含两个整数 $n$ 和 $t$ ($1 \le n \le 100\,000, t \ge 1$),分别表示 Robby 程序长度和电池持续时间。第二行包含一个由 $n$ 个整数组成的序列 $d_1, \dots, d_n$ ($1 \le d_i \le 10^9$),表示程序的连续指令。第三行包含一对整数 $x$ 和 $y$ ($-10^9 \le x, y \le 10^9$),表示目标点的坐标。

输出格式

输出一个整数:Robby 位于点 $(x, y)$ 的次数,如果适用,包括第 $0$ 秒和第 $t$ 秒的情况。

样例

输入 1

4 28
2 3 1 2
3 2

输出 1

2

说明

Robby 在启动后的第 6 秒和第 22 秒位于点 $(3, 2)$。下图描绘了 Robby 的路线:

子任务

测试集由以下子集组成。每个子集内可能包含多个单元测试。

子集 属性 分值
1 $t \le 10^6$ 10
2 $t \le 10^{12}$ 且 $10^6 \le d_i$ 30
3 $t \le 10^{18}$ 60

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.