Educational Codeforces Round 116 ABCE Solutions (Java/C++)

A. AB Balance

Solution:

Obviously, if the beginning and ending letters are the same letter, AB(s) must be equal to BA(s).

Code:

Java

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

C++

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

B. Update Files

Solution:

Before running out of k patch cables, copy as many files as there are computers. If there are more than k computers with files, just copy k files at a time.

Code:

Java

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

C++

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

C. Banknotes

Solution:

Obviously, we want to use the lower bits as much as possible. Therefore, we calculate the corresponding available[i] according to the values of a[i] and a[i+1]: $available[i]=10^{a[i+1]-a[i]}-1$.
Take a[2]=3, a[3]=5 as an example, then 1000 can use up to 99 banknotes. Once 100 banknotes are used, they can be replaced with one banknote of 100,000.
But for a[1], although available[i]=999, because it can't be represented, only available[1]-1 can be used at most for i=1.

In addition, if available[1] itself is larger than k, then k banknotes of 1 can be used directly.

Code:

Java

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

C++

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

E. Arena

The final time complexity of this problem can be directly inferred based on the scale of its data, so the solution can be naturally thought of.

Educational Codeforces Round 116 Arena Solution (Java/C++)
Solution:Based on the size of the data, we can almost infer that the final complexity should be $n\cdot x$.
Click the link above for detail solution
DigitalOcean Referral Badge 蜀ICP备19018968号