Codeforces Round #726 ABCD Solutions (Java/C++)

A. Arithmetic Array

Solution:

For the sum less than n, we just need append one number to make the sum equal to n.

For the sum more than n, we append some zero to make n equal to the sum.

Code:

Java

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

C++

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

B. Bad Boy

Solution:

No matter where the initial position is, the result must be two opposite corners. So, just print 1 1 n m.

Code:

Java

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

C++

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

C. Challenging Cliffs

Solution:

After sort by the height. Two adjacent numbers with the smallest difference can be selected as one head and one tail.

To have the highest cost, it is necessary to keep the array single increment as much as possible. So, we can do something below:

Code:

Java

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

C++

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

D. Deleting Divisors

The breakthrough is the initial value is odd. Because the odd number only can be transfer to even number. Then we separate the initial value to 3 categories, and just find the status transition.

Codeforces Round #726 Deleting Divisors Solution (Java/C++)
Solution:We can separate the number to 3 categories: odd, even but not include $2^n$ and $2^n$. Then we can get the state transition brought by one step operation:

I am too tired these few days. Even problem E and F lower than 2500. But I do it later.

Show Comments
DigitalOcean Referral Badge