Codeforces Round #751 (Div. 2) ABCD Solutions (Java/C++)

A. Two Subsequences

Solution:

Obviously the string a will only have one letter. We only need to find the smallest letter in the original string.

Code:

Java

Submission #133520784 - Codeforces
Codeforces. Programming competitions and contests, programming community

C++

Submission #133521057 - Codeforces
Codeforces. Programming competitions and contests, programming community

B. Divine Array

Solution:

Solve it by brute force until all the numbers no longer change. The reason for the value change is: in the last change, there were two numbers which the number of it are the same.

So obviously, after this operation is performed up to 2000 times, all numbers will become the same number.

Code:

Java

Submission #133526118 - Codeforces
Codeforces. Programming competitions and contests, programming community

C++

Submission #133526518 - Codeforces
Codeforces. Programming competitions and contests, programming community

C. Array Elimination

Solution:

Obviously, if you want to delete 1 in a certain bit, then the k selected numbers are all 1 in that bit. At the same time, after each operation, all 1s in this bit will become 0. Therefore, k must be able to divide the number of  numbers which the certain bit is 1 and your want to remove it.

Therefore, count the numbers for each bit where the certain bit is 1 and take the greatest common divisor.

Code:

Java

Submission #133530322 - Codeforces
Codeforces. Programming competitions and contests, programming community

C++

Submission #133530619 - Codeforces
Codeforces. Programming competitions and contests, programming community

D. Frog Traveler

The key point of this problem is to convert slippage into a part of jumping operation.

Codeforces Round #751 (Div. 2) Frog Traveler Solution (Java/C++)
Solution:First of all, because after reaching 0, there will be no slip. Therefore, we consider slip as part of the ability to jump.
Click the link above for detail solution
Show Comments
DigitalOcean Referral Badge