Educational Codeforces Round 118 ABCDE Solutions (Java/C++)

A. Long Comparison

Solution:

First, we can compare the digits of x. If the digits are different, we will continue to multiply the number with less digits by 10 until the digits are the same.

Then compare the adjusted p. If p is the same, then compare x.

Code:

Java

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

C++

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

B. Absent Remainder

Solution:

Obviously x mod y <x. Therefore, we always choose x as the minimum value of the array, and then y can be chosen from the remaining numbers.

Code:

Java

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

C++

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

C. Poisoned Dagger

Solution:

Binary search for the value of k. Calculate the total damage according to the problem description each time.

Code:

Java

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

C++

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

D. MEX Sequences

This problem needs to think clearly about the ways of constructing it. With the construction method the DP will be more obvious.

Educational Codeforces Round 118 MEX Sequences Solution (Java/C++)
Solution:First, we consider what options are available to meet the conditions.Obviously [0, 1, 2, 3, 4, 5] is eligible, because for any i, x[i]-MEX(x[1],..., x[i])=-1.
Click the link above for detailed solution

E. Crazy Robot

Solution:

Starting from L, just DFS. Look for the cell that is a + each time, and then continue to search based on the + cell.

On the problem, C++ is easier to TLE than Java. Because the values of n and m vary widely, the speed of C++ dynamically generating and initializing a two-dimensional array seems not as fast as Java.

Code:

Java

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

C++

Submission #138364073 - Codeforces
Codeforces. Programming competitions and contests, programming community
Show Comments
DigitalOcean Referral Badge