PivotOJ

A Stack of Gold

시간 제한: 1000ms메모리 제한: 2048MB출처: ICPC ECNA 2024-2025BOJ 32805

문제

Lt. Columbo, arguably the best detective in the world, was faced with a problem. He was asked: if he was placed in a room with some number of stacks of gold-colored coins, where all but one stack consisted solely of tungsten coins, and the remaining stack consisted solely of pure gold coins, how could he determine which stack had the pure gold coins? Oh, excuse me, there's just one more thing... he was also told he is given a modern penny scale and one penny. A modern version of the penny scale operates as follows: when you deposit a penny and put an object (or objects) on the scale, the machine displays the weight on a digital display. The scale is extremely accurate, down to milligrams. Every coin is the same size and color, but the tungsten coins weigh 2926029\,260 mg each and the gold coins weigh 2937029\,370 mg each.

Being the genius that he is, Columbo came up with the solution to figure out which stack contained the gold coins using a single weighing (since he has only one penny for the penny scale). As an example, suppose there are four stacks of coins labeled 11 through 44. If he took one coin from stack 11, two coins from stack 22, three coins from stack 33 and four coins from stack 44, and weighed those 1010 coins together on the penny scale, he could determine which stack had the gold coins. "How?" you might ask. Suppose all four stacks were tungsten. The total weight of the 1010 coins would be 292600292\,600 mg. If, say, stack 11 was gold (one gold coin in the pile that was weighed), the total weight would be 292710292\,710 mg. If stack 22 was gold (two gold coins in the pile that was weighed), the total weight would be 292820292\,820 mg. So, if you know the number of coins being weighed and the total weight of those coins, you can determine which stack has the gold coins. Just as a reminder, given a number of stacks, ss, the number of coins, cc, being weighed will be:

\[c = \frac{s(s+1)}{2}\]

입력

Input consists of a single line containing two integers ww ss, where ww (87890w14777400087\,890 \leq w \leq 147\,774\,000) is the weight in milligrams reported by the scale and ss (2s1002 \leq s \leq 100) is the number of coin stacks. The stacks are labeled 11 to ss with ii coins from stack ii moved to the scale for 1is1 \leq i \leq s. For given values of ww and ss, it will always be possible to determine which stack is composed solely of gold coins.

출력

Output consists of a single positive integer indicating which stack contains the gold coins.

예제

예제 1

입력
292930 4
출력
3

예제 2

입력
147774000 100
출력
100
코드를 제출하려면 로그인하세요.