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

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

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

C++

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

B. Plus and Multiply

Solution:

It is not difficult to find that if n is in the set, then n must be expressed as $a^x+y\cdot b$, where $x\geq 0, y \geq 0$. So, it just needs enumerate the x.
For example, $(a+b)\cdot a + b$, it is equivalent to $a^2+b\cdot(a+1)$.

Code:

Java

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

C++

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

C. Strange Function

The key to this question is that: As the value of f(i) increases, the remaining i cannot be divisible by any existing number, and therefore cannot be divisible by the least common multiple of all existing numbers.

Codeforces Round #729 Strange Function Solution (Java/C++)
Solution:First, we can note that: when i is odd number, f(i)=2.Then we consider the case that f(i)=3. Based on the definition, if and only if i is even number and i cannot be divisible by 3, then f(i)=3.
Click the link above for detail solution

D. Priority Queue

The main key of this question is to transform the question into how many seed sequences each number can appear in. And pay attention to some details in the calculation process.

Codeforces Round #729 Priority Queue Solution (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].
Click the link above for detail solution
DigitalOcean Referral Badge 蜀ICP备19018968号