# CF92A Chips

• 134通过
• 198提交
• 题目来源
• 评测方式 RemoteJudge
• 标签 数论,数学 概率论,统计 模拟
• 难度 入门难度
• 时空限制 2000ms / 256MB
• 提示：收藏到任务计划后，可在首页查看。

## 题目描述

现在有n个海狮坐成一个圆圈玩♂游♂戏。所有海狮都被顺时针的被编上号码了：2号海狮在1号海狮的左边坐着，3号海狮在2号海狮的左边坐着，……，1号海狮在n号海狮的左边坐着。

我们还有一位慷慨的来自某薯片公司的员工。他为了宣传他的薯片有多好吃，带来了m片薯片来到海狮群做宣传。他站在海狮圈的中间并顺时针转动。第i号海狮可以分到i个薯片。如果这位员工没有足够的薯片，这个黑心的员工就带着剩下的薯片跑了。现在给你n和m，让你求这个员工最后会拿多少薯片。

## 输入输出格式

### 输入格式

一行，包含两个整数n和m。（1<=n<=50，1<=m<=10^4）

### 输出格式

输出这个员工带着多少薯片跑了

## 题目描述

There are $n$ walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number $2$ sits to the left of the walrus number $1$ , the walrus number $3$ sits to the left of the walrus number $2$ , ..., the walrus number $1$ sits to the left of the walrus number $n$ .

The presenter has $m$ chips. The presenter stands in the middle of the circle and starts giving the chips to the walruses starting from walrus number $1$ and moving clockwise. The walrus number $i$ gets $i$ chips. If the presenter can't give the current walrus the required number of chips, then the presenter takes the remaining chips and the process ends. Determine by the given $n$ and $m$ how many chips the presenter will get in the end.

## 输入输出格式

输入格式：

The first line contains two integers $n$ and $m$ ( $1<=n<=50$ , $1<=m<=10^{4}$ ) — the number of walruses and the number of chips correspondingly.

输出格式：

Print the number of chips the presenter ended up with.

## 输入输出样例

输入样例#1： 复制
4 11

输出样例#1： 复制
0

输入样例#2： 复制
17 107

输出样例#2： 复制
2

输入样例#3： 复制
3 8

输出样例#3： 复制
1


## 说明

In the first sample the presenter gives one chip to the walrus number $1$ , two chips to the walrus number $2$ , three chips to the walrus number $3$ , four chips to the walrus number $4$ , then again one chip to the walrus number $1$ . After that the presenter runs out of chips. He can't give anything to the walrus number $2$ and the process finishes.

In the third sample the presenter gives one chip to the walrus number $1$ , two chips to the walrus number $2$ , three chips to the walrus number $3$ , then again one chip to the walrus number $1$ . The presenter has one chip left and he can't give two chips to the walrus number $2$ , that's why the presenter takes the last chip.

提示
标程仅供做题后或实在无思路时参考。
请自觉、自律地使用该功能并请对自己的学习负责。
如果发现恶意抄袭标程，将按照I类违反进行处理。