Codeforces Round #734 ABCDE Solutions (Java/C++)
A. Polycarp and Coins Solution: Divide n by 3. If the remainder is 0, then c1 and c2 are equal; if the remainder is 1, then c1 has one extra; if the remainder is 2, then c2 has one extra.…
A. Polycarp and Coins Solution: Divide n by 3. If the remainder is 0, then c1 and c2 are equal; if the remainder is 1, then c1 has one extra; if the remainder is 2, then c2 has one extra.…
A. Find The Array Solution: Just be greedy. Press 1, 3, 5, 7 and so on in sequence, and stop as long as the sum is greater than s. Code: Java C++…
Solution: First, let us pay attention to the range of l and r, $l\leq 1$, $r\geq n$. So, for the first half of a, you can let $a[i]=i+1$, and for the second half of a, you can let $a[i]=i-1$.…
A. AquaMoon and Two Arrays Solution: Just simulate the process. For each time, find the i,j where a[i]>b[i] and a[j]<b[j]. Just apply the operation for this i, j. Code: Java C++…
A. Shortest Path with Obstacle Solution: If and only if the three points of ABF are in a straight line and F is between AB, the answer is Manhattan distance +2.…
A. Exciting Bets Solution: If the two numbers are the same, then obviously the answer is infinity. If the two numbers are different, then let us represent these two numbers to a and a+x.…
A. Odd Set Solution: Just need count the number of even numbers. If and only if the number of even numbers and the number of odd numbers are the same, then we output "Yes" Code: Java C++…
Solution: First, for each + operation, we only need count the number of subsequences which include this operation. Let us assume the i-th operation is +, and the value of it is a[i].…