Codeforces Round #748 Red-Black Number Solution (Java/C++)
Solution: A very obvious DP problem. It is not difficult to think of several states: 1. The first i numbers; 2. |r-l|; 3. The remainder of division by A; 4. The remainder of division by B.…
Solution: A very obvious DP problem. It is not difficult to think of several states: 1. The first i numbers; 2. |r-l|; 3. The remainder of division by A; 4. The remainder of division by B.…
A. Computer Game Solution: Scan from left to right one by one. As long as one of the columns on the left can be reached, all safe cells in the current column can be reached.…
A. Consecutive Sum Riddle Solution: Obviously $\frac {(l+r)\cdot (r-l+1)} 2 = n$, so $(l+r)\cdot (r-l+1) = 2\cdot n$.…
A. Gamer Hemose Solution: Obviously, we only need to choose the two weapons with the highest attack power to attack alternately. Code: Java C++…
Solution: First, if the XOR of each component is the same (represent by X), then the XOR of all nodes is either X or 0.…
Solution: First, because gcd(a,b,c) must be less than or equal to gcd(a,b) or gcd(b,c). Therefore, the maximum distance must be the largest side.…
A. CQXYM Count Permutations Solution: It is not difficult to think that there are x of i satisfying the condition in an permutations , then if we reverse the permutations, there are 2n-x of i satisfying the condition.…
Solution: First of all, we can almost immediately notice that if x[i]>m, then this must have no effect, and we can ignore it directly. Therefore, the value range of x[i] is reduced from 0~$10^9$ to 0~$2\cdot 10^5$.…