AliceGameEasy
SRM 639 · 2014-08-25 · by dreamoon
Problem Statement
Alice and Kirito just played a game. The game consisted of a finite (possibly empty) sequence of turns. You do not know the exact number of turns. The turns were numbered starting from 1. In each turn, exactly one of our two players won. The winner of turn i scored i points.
You are given two
Constraints
- x and y will be between 0 and 1,000,000,000,000(10^12), inclusive.
7 14 Returns: 2
This final result is possible. One possibility is that Alice won turns 1, 2, and 4 (for 1+2+4 = 7 points) and Kirito won turns 3, 5, and 6 (for 3+5+6 = 14 points). However, there are also some other possibilities in which Alice only won two of the six turns, so the correct answer is 2.
10 0 Returns: 4
There must have been four turns and Alice must have won all four of them.
932599670050 67400241741 Returns: 1047062
Watch out for integer overflow.
7 13 Returns: -1
0 0 Returns: 0
Submissions are judged against all 65 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class AliceGameEasy with a public method long long findMinimumValue(long long x, long long y) · 65 test cases · 2 s / 256 MB per case