Codeforces Round #748 All are Same/Half of Same Solutions (Java/C++)
Solution: D1. All are Same First, if all numbers are the same, then k can be any value. So we only need to consider the situation where there are different numbers.…
Solution: D1. All are Same First, if all numbers are the same, then k can be any value. So we only need to consider the situation where there are different numbers.…
Solution: First of all, according to the description of the problem, we can know that the direction of the brackets does not affect the result at all. So naturally, we only need to consider the parity of different types of brackets.…
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.…