Skip to content

List Game with Marbles (Hard Version)Array and PermutationFriendly Numbers

Friendly Numbers

A number theory problem. We know that y and d(y) is same module 9, so one necessary condition is x should be times of 9. And we know that the . Obviously, the range is less than 100. So we solve it with hand.

Array and permutation

Array b is actually a scratch of element in array a. So we remove the duplicated elements. And with two points, we search if the selected elements occur in the array a. But i think that this problem can be abstract into the inversion.

Game with Marbles

We can find that the contribution Alice do if Alice choose is $$(a_i - 1) - (-(b_i - 1)) = a_i + b_i - 2$$ and for Bob is also this but is negative. So we can manipulated the operation of Bob. First we construct a variable cnt equals to $$S = \sum (a_i - 1)$$ and begin with idx 1 we calculate -.