Educational Codeforces Round #107 ABCD Solutions

A. Review Site

Solution:

Put all type 2 users a server. And put type 1 and type 3 users to another one. Then all type 3 users will upvote.

Code:

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

B. GCD Length

Solution:

Let $gcd(x,y)=10^{(c-1)}$,  $x=gcd(x,y)\cdot{2^?}$ and $y=gcd(x,y)\cdot{3^?}$. Then only need enumerate the ? to make the length match requirement.

Code:

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

C. Yet Another Card Deck

Solution:

There are up to 50 colors. Maintain the smallest index for each color.

For each operation, +1 to the index of colors in front of the current card previously.

Code:

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

D. Min Cost String

Solution:

Let's put out all permutations of two letters first. So $aa$, $ab$, $ac$, $ba$, $bb$, $bc$, $cc$……

Then we can find that: $aaab$ include 3 $a$, which will increase the cost. So for $aa$ we only keep one of $a$ in the result.

And consider $abac$, it's already included $ba$. So for each alphabet $s_0$, the alphabet after it ($s_1$) is starting from $s_0$. For example $c$ is start from $cc$, not $cb$.

So we can list down all the permutations except two case above. Keep repeating until the length reaches $n$.

Code:

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