values. In one move you may:
1. pick two elements at different positions, both greater than zero, call them x and y (order matters);
2. remove both from the list;
3. append the remainder x mod y to the end.
Each move shortens the list by one. You may make any number of moves, including none. Return the smallest length the list can be shrunk to.values=[6, 4, 6] → 1
Take 6 and 4: 6 mod 4 = 2, giving [6, 2]. Then 2 and 6: 2 mod 6 = 2, giving [2]. One element is left.
values=[3, 3, 3, 9] → 2
Every value is a multiple of 3, and nothing positive smaller than 3 can appear. The pair (3, 9) gives 3, then two pairs of 3s give two zeros: [0, 0]. That is the best possible.
values=[11] → 1
len(values) ≤ 10⁵values[i] ≤ 10⁹values=[6, 4, 6]
1
Run checks the first 3 tests in your browser. Submit checks all 137 tests on the server, hidden ones included.