Hello Codeforces!

On August 3, 18:05 MSK Educational Codeforces Round 26 will start.

Series of Educational Rounds continue being held as Harbour.Space University initiative! You can read the details about the cooperation between Harbour.Space University and Codeforces in the blog post.

The round will be **unrated** for all users and will be held on extented ACM ICPC rules. After the end of the contest you will have one day to hack any solution you want. You will have access to copy any solution and test it locally.

You will be given **7 problems** and **2 hours** to solve them.

The problems were prepared by Ivan BledDest Androsov, Alexey Perforator Ripinen, Mike MikeMirzayanov Mirzayanov and me.

Good luck to all participants!

Don’t miss your chance to be a part of this leader board in the next ACM-ICPC World Finals by reserving your spot in the 2nd Hello Barcelona Programming Bootcamp in collaboration with Moscow Workshops ACM ICPC.

Check out the winning statics of Universities that participated in this special training — *World Finals 2017 Results*.

**8 out of 12 prize-winners of the World Finals 2017 participated in Moscow Workshops ACM-ICPC!**

Take a look back on our previous "Hello Barcelona ACM-ICPC Bootcamp, in collaboration with Moscow Workshops ACM-ICPC". Students and coaches from all over the globe gathered at our campus to learn from and work with the world’s top programmers, soak in the Barcelona sun, and share in the comradery built within the programming community. Harbour.Space University is looking forward to hosting again, this time at the beautiful and technologically mind bending Media-TIC building.

UPD: Editorial is available

delayed by 10 minutes

I thought no one has noticed the delay because until 4 min ago there is no comment but it was delayed 10 min before original starting time

maybe they focus on the problems not announcement :)

Hi first thx for preparing the contest But Why So delay?!

why not?:)

maybe someone schedule for the time :)

20 minutes penalty for wrong submit is too much for 2-hours contest, don't you think? What about decreasing this value for educational rounds?

Well, mostly I can agree with you, 20 minute penalty for any little bug, is a bit too huge, but on the other hand, it's EDUCATIONAL round, so scores doesn't really matter. Here the only goal is to improve, not to compete with others.

How to solve E?

Still a minute to go.

I have known how to solve E,but it's too late!

How to solve D, I think it's dp but I can't find it. :'(

You can notice that the roundness is equal min(v1, v2) where v1 = number of 5 in a number, and v2 is number of 2 in a number. So just do dp[size_of_subset][number_of_5] = max_number_of_2.

First: the number of trailing 0's is the minimum number of 2-factors or 5-factors.

So now we just have to pick a subset to maximize this minimum. I solved it via a knapsack with 2 states, the number of element in the subset, and the number of 5-factors.

dp[i][j][L] = max number of 2 when choosing j numbers from the first i numbers, with a total of L 5's. L won't be larger than 5000 (5^26>10^18).

By the way, that's 200*200*5000=2*10^8 operations, why it works so fast(under 200ms)?

29170931

Is it because they haven't included stronger test cases yet?

Any test with n = k = 200(test #21) should be the slowest for my code.

so have you figured out why is it so fast?

Why it should be slower? It's absolutely normal time for such amount of simple operations.

UPD: The following is wrong. The solution is an N^3 DP.I just tried the problem, did the following DP.

The first observation is that, for any point, the total number of zeroes = min(number of twos, number of fives).

Let twos[i] = number of twos in the number at the ith index, fives[i] = number of fives in the number at the ith index.

Declare dp[i][j] as a pair, dp[i][j].f = number of twos in our set, dp[i][j].s = number of fives in our set.

dp[i][j] = best subset we can make until index i with j numbers in our subset.

If

min(dp[i — 1][j].f, dp[i — 1][j].s) > min(dp[i — 1][j — 1].f + twos[i], dp[i — 1][j — 1].s + fives[i]), dp[i][j] = dp[i-1][j].Else, dp[i][j].f = dp[i — 1][j — 1].f + twos[i], dp[i][j].s = dp[i — 1][j — 1].s + fives[i].Answer is min(dp[N][K].f, dp[N][K].s). Complexity is

O(N^2).Hacked you with this case:

Nice! Sorry for the confusion, my solution got accepted on the normal tests so thought I was good. Guess I'll go with the N^3 DP. Initial logic is flawed on cases with separate twos and fives :D. Edited my comment. Thanks!

It can't work because you cannot count dp with only those informations. You don't know what is best pair. Maybe optimal solution is take one number power of two and next one power of 5.

How to solve D?

I did DP[i][k][s] — a maximal number of 2 in prefix [1..i] when we take k numbers and product of those numbers has s factors equal 5.

1 <= i,k <= n , 0 <= s <= 5000

It was too slow.

It wasn't too slow, you got mle, so you just needed to keep the only last layer of dp.

i did the same and my solution works under 100ms.

OK, I had a bug.

is solution for D Dp state reduction?

Problem E is so interesting and I think it's original problem, it would be better if it was used in rated contest (if it's indeed original)

very nice problem indeed...I couldn't solve it during the contest..any hints???

notice that gcd(a , b) always increases in this process , so for a particular value of b , find the max

b' <bwhere gcd(a,b') >gcd(a,b) , this can be done inO(P) time where P is the number of distinct prime factors ofa, and since number of distinct gcds are , total complexity isA better bound than on the number of iterations is as in ever step gcd gets multiplied by some integer >= 2.

I was thinking is the max number in array A^j is sum A[i]*binomial(j+n-i, n-i)? How to calculate binomials fast enought?

Oh its F :D

I was enjoying this contest. Short description and interesting problems. :)

Hey, Can anyone tell me why my code failed in Test #15 of Problem B. Here's a link : My Solution

can you tell me why it is no for test#10?

Hints for F?

I think brute-force can solve F, for the answer won't be too large if n>3 (after removing leading zeros). When n=2 or n=3, we can use binary search. However, the overflow problem troubled me a lot, so I didn't complete this method during the contest :(

We can do binary search every time if we succeed to calculate binomial coefficients :D

How exactly the binary search part works?

Max number is rightmost. It is just sum of elements using binomial coefficients. It comes from pascals triangle property what A[i, j]=A[i-1, j]+A[i, j-1].

When

n= 3 andarr= [a,b,c], onm-th iteration we have third number in array equal to , so we can use binary search to find firstm, for which this value is ≥k.3 100 BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRG why answer is no for this test case??

It has G in a row of R.

there's a 'G' at the end of the last row...because of that there are not three stripes of different colors to make a valid flag

Can D be solved faster than

O(Cn^3), where C islog5(1e18)?Do red coders use some kind of script for hacking or something?

One refresh in my status page shows 2-3 hacks by halyavin

(please tell me your secret :v )

Only 2-3? Sometimes before I saw uwi had +55 hacks .. Just after 1 minute I refreshed page and saw +77 :| Now it is +124+ \m/

you can't say only 2-3 :v your rate is (77-55)/60s which is less than (2)/2s So I am ahead of you in observing this phenomenon 8-)

When do we get editorials for this contest ?

In couple of hours

Thanks PikMike :)

what is hack test for D except this one :

3 2

4 10 25

If our code is hacked then can we see the hack case? If so how?

During hacking time, only hackers know the case. I think it is good to send message to the hacker.

Ohh ok alright. I'll do that. Thanks!

Also can you please tell me that if I submit a solution now does it run on stronger test cases or the pretests from the edu round?

Sorry I'm not sure. Let's check in this round.

i guess on stronger tests but still people can hack you:)

They add all succesful hacks' cases to system tests in practice.

Auto comment: topic has been updated by PikMike (previous revision, new revision, compare).Why are they showing rating change on the right hand side??????!!!!!! its so sad that we cant get that!! its like they are teasing us!

I don't see any rating, i think you have some rating predictor extension installed.

hmm, could be!

When would Solution of this problem be provided?