QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 1024 MB Total points: 100

#2460. 抢椅子游戏

Statistics

Faber 学院音乐系的 O’Dagio 教授想出了一种非常有趣的系主任选举方式。音乐系的所有 $n$ 名教职工排成一列,队列中的第一位成员报出一个整数 $k$,对应他/她最喜欢的 Faber 学院最杰出的校友、作曲家 I. M. Tondeff 的作品编号。随后,系里的成员开始“报数”,从队列中的第一人开始,必要时循环回到队列开头。当报数达到 $k$ 时,该人退出队列,并(在某种意义上)免除了当年的系主任职责!

接下来队列中的下一个人报出他/她最喜欢的作品编号(这成为新的 $k$ 值),报数重新从“1”开始,直到下一个人被淘汰,以此类推。当只剩下一名教职工时,他/她就是新的系主任。为了防止作弊,每个人的最爱编号都会提前公布,且不允许任何人选择 Tondeff 的作品 1(著名的饮酒歌《Rhapsody in Brew》)。

例如,假设教授们编号为 1 到 4 并按此顺序排队;假设他们最喜欢的作品编号分别为:作品 8(《The Four Sneezings》)、作品 2(《Concerto for Kazoo and Cigar Box Banjo》)、作品 4(《The Taekwondo Rondo》)以及作品 2(再次)。图 F.1 展示了选出新系主任的过程。

图 F.1:选举过程示例

输入格式

第一行输入包含一个整数 $n$ ($2 \le n \le 10^4$),表示教职工的人数。下一行包含 $n$ 个整数 $k_1 \dots k_n$ ($2 \le k_i \le 10^6$,对于每个 $i$),其中 $k_i$ 是教授 $i$ 最喜欢的作品编号。

输出格式

输出新系主任的编号。

样例

输入 1

4
8 2 4 2

输出 1

3

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.