AtCoder Beginner Contest 105 is ongoing now, from August 11, 2018, 21:00 JST.

The writers are DEGwer, Drafear, square1001 and me.

The point values are: 100 — 200 — 300 — 400.

This contest will be unrated because of problems in English statement. At first, there is no English statement in problem A. 6 minutes after starting the contest, the English statement appeared, but it was too late. Sorry for inconvenience.

After the contest, let's discuss the problem.

Thank you for your participation.

**UPDATE**

- The contest is over.
- Japanese Editorial is there!
- English Editorial is ready!

Auto comment: topic has been updated by E869120 (previous revision, new revision, compare).We (E869120 and I) made problem B "Cakes and Donuts". The other problems were made by other writers. We maybe publish the English editorial of B (unofficial one, we can maybe translate the other one) in codeforces comment tomorrow, but

it is strongly encouragedto discuss about the problems in the round (even before the unofficial editorial publishing).UPD: We're sorry that we cannot create English editorial today, and it will be published tomorrow. The main reason was, during the contest, we were on trip to somewhere (which were no Wi-Fi, and we actually used tethering). But since the contest was unrated, we had to do too many actions on the Internet and used more than half of this months' cellular network (?) contract.

Now uploaded! (Aug. 13th, 2018)I hope that Atcoder has its own page for discussion...

Here is my Editorial of D in English. Lets denote

f(i) equal to sum of elementsa_{j}wherejis between 1...i. More formally . As problem says we need to find suchlandrthat . We can transferf(l) into right side, then our equation will be . We can easily find it with`Red Black Tree`

. As you see, our time complexity will be O(NlogN).Can we solve D with two pointers after calculation of f?

No because we use

`mod`

operation.or simply use

`map`

std::map is a kind of Red-black tree.

We don't need

`map`

though, just sorting. We can just sortfand for every groupgof consecutive equal elements, add to the answer.In problem B, you can just simply calculate with 2 loops. Or you can solve it with Bézout's identity. More detailed you can read there.

Are statement was in Japan language only ? I used google translate.

English statements added later. That's why contest unrated.

I think it's not big problem because we have google translate and also many people used it :)

but statement translated by google translate for problem A is incorrect

When will the next regular contest be held? It is already one month since the last regular contest on AtCoder.

Considering this comment, ARC/AGC is likely to be held two weeks later, at the earliest.

As a Brute-force search for problem C, there is a solution by meet in the middle. For example, we have all the values for whether the even bit (0, 2, ..., 30) is set (in -2 binary) or not, and do the same thing with odd bit (1, 3, ..., 31) , then find a pair that will become n together. With N = 32, the time complexity is

O(N2^{N / 2}). Of course, it would be nice if you could implement a smart solution like the assumed solution, but such a steady solution is sometimes useful.Also you can with this method

I mean, I understand problem C can be solved in O(logN). But we can not always come up with such a solution, and In many cases div2 and ABC are asked about the implementation capability of brute force search.(like yesterday CF div2 B,C) In addition, since the range of solvable problems for you is broadened by using various solutions to one problem, I presented a solution by meet in the middle.

How do you prove that the number will fit in 30 bits? As there is negative base, we can't assume that it will fit in log(n) bits?

The following is my C++14 iterative

O(logN) solution of problem C.Base -2 Number System

The solution is based on the simple equation 2

^{k}= 2^{k + 1}- 2^{k}When

kis an odd number, the one bit 2^{k}in a Base 2 numberNcorresponds to one bit in Base -2 System - 2^{k}by adding 2^{k + 1}toN. Using the bitwise shift right operator iteratively after pushing the least significant bit ofNto a bit stack, the previous equation corresponds to incrementingNby 1 after shifting it to the right 1 bit whenkis an odd number. The loops stops whenN= 0, and the requested string is printed to the standard output by popping the bits from the stack.The following is my C++14 map-based solution of problem D.

Candy Distribution

Let

s_{i}, where 0 ≤s_{i}≤M- 1, be the cumulative sum ofA_{i}moduloM. The condition that the summation ofA_{i}in the index interval [l,r], where 1 ≤l≤r≤N, should be a multiple ofMis equivalent to the condition that eithers_{r}≠ 0 ands_{l}=s_{r}, wherel≠r; ors_{r}= 0 and eitherl= 1 ors_{l}= 0Let the number of elements in

Afor each cumulative sumsbeg(s), which can be computed using acountmap data structure. The number of intervals [l,r] associated withswhose summation is a multiple ofMcan be computed as follows.If

s≠ 0, thenIf

s= 0, thenSumming

count(s) over all existing values ofsin thecountmap produces the required answer.is It late in rating update?

it's unrated !!

ok, thanks.

it could be rated.

The task C is just a copy of the problem F from this contest. D is very similiar to this one

Concerning problem "D — Candy Distribution", I used binomial coefficient template accidentally and found it couldn't get through all tests case except "0_min1" case. Forgive me that I was so stupid to calculate C(n, 2) with a template. I really want to know if the method is right to calculate binomial coefficient.

And this is my contest code for problem D: https://pastebin.ubuntu.com/p/F88GgY26Vq/

Yes, it is right except for the case when

k>n. Your present implementation returns 1 in this case, but the correct value is 0.You should add the following lines at the beginning of the function

This should fix the problem.

Thank you so much. It really works. ;)

With pleasure

I missed this contest unfortunately. If I had known it was conducted by my favourite problem setting twins E869120 and square1001 I would have tried to participate.

I upsolved it now and found it a bit on the easier side.

I have written an editorial for D here because there was no English editorial available and it might be helpful for some people.

P.S. — I liked the mathematical solution to Problem B a lot. And Problem C was also quite elegant :)

Can you explain C?

Explanation is available here. If you have any doubts, let me know.

Auto comment: topic has been updated by E869120 (previous revision, new revision, compare).We've finally wrote the English editorial! We (E869120 and I) only wrote the problem B, but we were able to write English editorial for all problems in less than 100 minutes. The editorial can be seen from the link at the blog statement.

We believe that we wrote detailed one, and for problem C and D, the editorial could be detailed than the official Japanese one! Let's enjoy!

Last but not least, the contest was unrated, and as organizers, we felt some duty of compensating the incident. We actually checked whether the English problem statement of B is uploaded, but if we checked that for all problem, we could have avoided the unrated. That's one of the reason we wrote English editorial.

- E869120, square1001

can any one explain problem c ?