102270: [AtCoder]ABC227 A - Last Card

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Score : $100$ points

Problem Statement

We will hand out a total of $K$ cards to $N$ people numbered $1, 2, \ldots, N$.

Beginning with Person $A$, we will give the cards one by one to the people in this order: $A, A+1, A+2, \ldots, N, 1, 2, \ldots$. Who will get the last card?

Formally, after Person $x(1 \leq x < N)$ gets a card, Person $x+1$ will get a card. After Person $N$ gets a card, Person $1$ gets a card.

Constraints

  • $1 \leq N,K \leq 1000$
  • $1 \leq A \leq N$
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

$N$ $K$ $A$

Output

Print a number representing the person who will get the last card.


Sample Input 1

3 3 2

Sample Output 1

1

The cards are given to Person $2, 3, 1$ in this order.


Sample Input 2

1 100 1

Sample Output 2

1

Sample Input 3

3 14 2

Sample Output 3

3

Input

题意翻译

**题目描述** 有 $n$ 个人,编号 $1$ 到 $n$ 。现在让他们按编号围成一圈,从编号 $a$ 的人开始按照 $a,a+1,a+2,...$ 的顺序轮流发卡片(当发到编号为 $n$ 的人时,下一张卡片发给 $1$ 号)。已知一共有 $k$ 张卡片需要发,请你算出发到最后一张卡片的人的编号。 **输入格式** 一行三个正整数 $n,k,a$ 。 **输出格式** 一行一个正整数,即拿到最后一张卡片的人的编号。

Output

分数:$100$分

问题描述

我们将向编号为$1, 2, \ldots, N$的$N$个人发放总共$K$张卡片。

从Person $A$开始,我们将按照这个顺序一张一张地将卡片发给人们:$A, A+1, A+2, \ldots, N, 1, 2, \ldots$。最后一张卡片会给谁呢?

正式地,当Person $x(1 \leq x < N)$得到一张卡片后,Person $x+1$将得到一张卡片。当Person $N$得到一张卡片后,Person $1$将得到一张卡片。

限制条件

  • $1 \leq N,K \leq 1000$
  • $1 \leq A \leq N$
  • 输入中的所有值都是整数。

输入

从标准输入以如下格式给出输入:

$N$ $K$ $A$

输出

打印一个表示将得到最后一张卡片的人的数字。


样例输入1

3 3 2

样例输出1

1

卡片按照Person $2, 3, 1$的顺序发放。


样例输入2

1 100 1

样例输出2

1

样例输入3

3 14 2

样例输出3

3

加入题单

算法标签: