**TREMBLE BEFORE THE MIGHTY OMEGALULGRAPE**

Hello Codeforces!

We are honored to invite you to Codeforces Round #538 (Div. 2), which will take place at 10.02.2019 17:05 (Московское время). The round will be rated for all Division 2 participants **(with rating less than 2100)**. Still, we warmly welcome Division 1 participants to join us out of competition.

You will be given **6** problems to solve in **2 hours.** The round's problems were initially prepared by Duy-Bach Akikaze Le, Xuan-Tung neko_nyaa Nguyen and Xuan-Quang xuanquang1999 D. Nguyen.

**There will be an interactive problem in this round.** Learn more about interactive problems here.

This is our first attempt in making a Codeforces round, so suggestions are much welcome to help us improve ourselves. ;)

We also want to thanks many friends for making this round possible:

- Dmitry _kun_ Sayutin for coordinating the round, providing a neat idea on one problem and some Russian translations.
- Andrew GreenGrape Rayskiy for various suggestions on the problems, some other Russian translations,
**and most importantly, peacefully submitted himself to be quarantined from pretests.**;) - Michal majk Svagerka for testing the round.
- And last but not least, Mike MikeMirzayanov Mirzayanov for the amazing Codeforces and Polygon platform, without which this round would never be possible :D

P/s: I will be at the Discord CP Community to discuss the problems after the coding phase. However, please follow the rules and don't discuss the problems during the contest by any means.

*Wish everyone good luck and high rating!*

**UPD1:** Score distribution: 500-1250-1500-2000-2000-2750

**UPD2:** Editorial is published.

**UPD3:** The contest is finished. I apologized for the "somewhat" weak pretests at here and there. Anyway, time to celebrate our winners ;)

**Official participants:**

- xlk200
- vasilescu_mihai
- Cinro_9baka
- africamonkey
- 2019_BecameMaster
- cdsfcesf
- yww_AFO
- hr_tian_xia_di_2
- JZmster
- chinmay0906

**Div.1 + Div.2 participants:**

Congrats on your first round!

i don’t understand any of this can someone explain

OMEGALULGRAPEALL HAIL THE MIGHTY OMEGALULGRAPEi am confused and you come here to make fun of me and confuse me even more? classic slav attitude...

GreenGrape everywhere...

Good Luck to All!

GreenGrape in two consecutive rounds, you must be joking

writing an announcement five days before a round -> bad round

At least it showed my bad patience :D

bad patience -> bad round

Is That Angel/Angle Said u to write so?? :thinking: sorry_marymarine

no, angel said to write a comment about dead boi

I think it's vice versa and it means that this round is important for him and he worked on it well.

important != worked well

Furthermore, important != bad work

Kuroyukihime round? awesome!

So far the round is not anime-themed...

... yet Lotus will not disappoint ya ;)

that's fantastic! i can not waiting anymore!

Vietnamese, raise your hand!!!!!

You speak the language of the trees?

No, the trees speak his language.

Good luck for your first round! I'm feeling some math here

first congrats on your first round second why interactive?

I dont know if I can ask this, but which is the interactive problem? C, D, E or F ???

All you need to know is there will be an binary search problem.

Or a magic random problem

With binary search.

On bits.

or HLD + FFT.

your wish was granted

Why did you wish for this bro :D

I knew you bro xD

Did anybody notice that there are less comments than shown in the blog.

Some spams were hidden by the administrators.

Dont worry guys Not every grape is Greengrape

Purple grapes taste better.

How about black grapes? :D

never knew they exist D:

romania!!! unite for this contest !!!

romani unitiva!!! acum ori niciodată!

I hope the difficult gap between problems can be proper.More personally,I hope there will be a problem(maybe problem D) whose difficulty is between 1700 and 1900.In recent contests,the gap between C and D is always wide(such as 1500 and 2200),which is ,to be honest, unfriendly to me(rating between 1800 and 1900).In many contests,I pass the first three problems in 30 mins and cannot solve problem D in remaining time.

Try problem E

Personally,this contest's problem E is easier than D for me.But I focus on D and fail,so I miss a chance to become purple.

Interactive problem，I'm not good at it,sad... Hope it won't be too difficult.

Hoping to finally be blue.

They didn't complete surgery on GreenGrape

Just a random fact, GreenGrape has never been

GreenGrape.He was! New year's magic :)

Why are there more and more Div2 rounds consisting of 6 problems nowadays? I think that this leads to more implementation and to less thinking. I think it's better when there is one interesting Div2E problem than 2 pure implementation Div2E and Div2F problems.

i will get grandmaster this round

good luck!

I believe in you!

I wished that there will be 6 nice problems and make me get some new skills in this contest. Thanks to the selfless dedication of the problem provivers.

what are you talking about i dont understand

tf you say to me you little

stop harassing people, you might get muted.

Auto comment: topic has been updated by Akikaze (previous revision, new revision, compare).Good Luck to All!

What will be the pattern of the points of every problem?

A 500 B 1250 C 1500 D 2000 E 2000 F 2750

what is pretest 10 for problem C?

I think it breaks some overflow checkers, namely the ones that test if your new product is less than your old product. You can have overflow and still have the new product be greater than your old ones, and in this case I believe it is because they had some prime that was greater than 4e9 that was getting squared.

"You can have overflow and still have the new product be greater than your old ones", how to handle this ?

You could use

`long double`

s for checking overflows or, possibly less stupidly, GCC's`__builtin_mul_overflow`

Or instead of

`n >= p * p0`

check`n / p >= p0`

.Thanks! It worked

Pretest 12 E?

RAND_MAX is 32767, u should extend it.

Oh my god...

So basically

`random_shuffle`

would not shuffle properly forN≤ 10^{6}?If this is the case then it is really bad problem setting because this is not something of common knowledge and many people would have encountered this error even though the had the solution.

Yes, but I think we can use some tricks to make it work in N<=1e6 even though it is not actually uniform distribution.

"The problem is bad if it requires some knowledge that I don't have"doesn't sound like a reasonable approach to me. The fact that random_shuffle() isn't very random by default is important thing to know, and your comment sounds like"It is bad to expect us to know that cout<<endl; is slow"or"It is bad to expect us to know that cache misses are slowing things down".It seems many people had the same issue so it isn't really common knowledge that inbuilt randomisation in C++ does not work properly for sizes greater than 32767.

I do not mean to disrespect the problem setters, but it does seem like this specific piece of knowledge is not known to many. Otherwise I would not have said anything like that. Although I do understand that if I am coding in C++ I should know it well enough to be able to code all kinds of solutions.

I still think that your reasoning makes little sense.

The fact that a lot of contestants don't know (or don't think about) something doesn't imply anything. I would agree if that was something very compiler-specific or CF-specific, like exploiting particular compiler bug that behaves clearly against the standard of C++ and has been introduced in particular version of compiler. I also didn't manage to get this problem initially, and it took me long time to figure out my mistake — but that's my fault, and not setter's.

Rabin-Vazirani algorithm isn't known to majority of CF users either, should we criticize any setter for deciding to use it for their problem? :)

Moreover, setters are so nice here that they even included this test in pretests. Can you imagine the mess we'd have otherwise? :)

Well I do agree to that. After all, someday someone had to make such a problem which would have highlighted this issue despite the fact that this has been posted in a blog earlier (because many people don't read blogs or simply don't happen to come across them). I guess this was inevitable.

Again, I don't mean to say this was setters' fault. All I wanted to say was that maybe the problem could have been set in a way that this issue would not have occurred (maybe setting

N≤ 10^{4}). But then this is also true for many other situations, like the need for fast IO (though I am not the setter so I don't have a say in this :P). In no way I mean to disrespect the setters, and I truly believe all setters do a great job at bringing us new problems to solve.In what sense is including this test different from including a test for the random generator of an arbitrary language? I could see which are the first 60 numbers the program would ask for and make sure they are not coprime positions. Also using any solution (assuming it does not seed on time) I can break it. I don't think this test adds to the quality of the problem and it is specifically targeted towards one of the allowed languages. Is there a test with the first 30 numbers the random of java would generate? Would you consider such a test fair?

Yes, I would consider it totally fair.

Moreover, your analogy sounds wrong to me. You don't need to know much about generator here — the solution is going to fail no matter what seed is used in generator.

You are complaining that the solution doesn't work because constraints are too large. That's like saying

"my solution with int didn't pass only because in your problem n<=1e18".I don't agree. It is like having the codeforces server using integers fit up to 2^15 and my solution failing because I had used int. On my machine and ideone rand() is not limited to 32k: https://ideone.com/r91m04 And c++ standard does not guarantee the size of int to fit 2^31: https://stackoverflow.com/a/589684/812912

What is the 12th pretest on E? I kept getting wrong answer on this one

Probably a test exploiting https://codeforces.com/blog/entry/61587.

I did this too,so I changed random_shuffle into my_rand.

what is the pretest #6 in D? ..

Can someone please explain how to solve D?

Does interval DP not work for problem D?

It does, my solution is df[from][to]

Interesting. I kept getting WA on pretest 6. What was your idea?

If the first and the last letter of the interval do not much you either will convert the longest prefix matching the first letter or the longest suffix matching the last letter. If the two letters match you will change both the longest suffix and the longest prefix on the last move.

So it seems that you're doing the DP by decreasing the size of the DP interval?

Yeap

I did my DP with increasing size of the DP interval (I suppose that should work?). I couldn't seem to come up with a counter case though.

It should at least pass the pretests I did something similar to your solution. Did you take every possible starting position?

My program should have accounted for every possible starting position. I guess the code speaks better for itself. 49731308

I think my transitions may be wrong but I'm not sure how.

I did it with increasing interval. you can have a look at my code- here

Thanks

I'm probably misunderstanding you, but I don't think what you said is true. If your array is 1 2 2 3, you can change this minimally to 2 2 2 2, which doesn't match the first or last letter.

Hmm no you can not. You have to change it first to 2 2 2 3 and then to 2 2 2 2

Ok, I misunderstood what you meant. I thought you meant that the prefix/suffix was going to match the exact color of the endpoints.

In any case, I see where my understanding of the problem was flawed.

What are the recursive calls? I imagine it's the classic (l+1, r) and (l, r-1), but sometimes you'll have to add 1 to your result, namely if it's not possible to get (l+1, r) to be the color of c[l] or (l, r-1) to be the color of c[r], but I couldn't find a good way to find when that's possible or not.

That is the typical way I implement DP — recursion with memoization

What to do in E after finding

Xn? I asked for 30 random values and tried to finddbased on these, but it doesn't have to be correcti do the same and pass the pretests

So I may have failed just because I forgot to delete the line where I was checking something...

how u calculate d ? i find all gcd between all pairs, smth like :

g = gcd(d, a[j] — a[i]) , for every i, j

I did the same and could not pass pretest 12

I had a list of all common divisors of differences. Final list could have more than 1 element, so d is last element in list, which is the greatest one. I made mistake here and said that d is first element of the list which is actually 1 :)

Use your own rand instead of C++ rand.

I had something like

`cout<<"xn is "<<xn<<endl;`

and didn't delete it. mt19937 should work for randomization btwIn fact u are findng at least 30 rand number and get their common gcd, if it is 1, the d is true. Actually, it is correct at most situations.

That seems to be the intended approach.

Probability of failure is very small. Let's assume that you found

dFakewhich is equal tok*d. This means that all your queries were lucky to hit position with same remainder modulok, and the chance for it is roughly (1 /k)^{NumberOfQueries - 1}.Why fail segment tree solutions and pass BIT solutions in F? (Offline, solve for each prime separately) -_-

My segment tree managed to pass the time limit.

https://codeforces.com/contest/1114/submission/49743195

This isn't the segment tree solution I was talking about. There is another approach using segment tree that solves the problem offline by handling one prime at a time and merging all answers. Such solution using segment tree gets TLE but BIT gets AC.

i think for about 40 minutes that's is sum in F instead of mult :(

I was literally begging for pretest 5 in 'C' :(when u are finding minimum your minimum keeping variable should be large enough initially even 9e9 did not work....but after this i got struck at pretest 10 :(

what is pretest 7 in C :(

I just checked how much each prime for b exists

and applied this func for each prime

long long factr(long long n,long long p) { long long po=0; for(long long i=p;i<=n;i*=p)po+=n/i; return po; } and then I got the result after division first array to the second (not sure if this is important to explain first array and the second )

what's the mistake maybe just tell me the right solution and I'll know it because I have no idea

Have you checked your data type? I changed from long long to unsigned long long, and passed Pretest 7.

that would make a difference in the function I wrote above ?

You may try remove

`i`

, and let`n /= p`

and`po += n / p`

instead. I passed the pretests in this way.Is there anything in your code to make sure that i*=p doesn't overflow long long?

The idea that you described sounds right.

yikes No what a sad mistake

And this is the silliest mistake i have made . WA on pretest 7, i think im gonna cry a lot today :-(

49731384 Can someone help me with this. I am getting WA on Pretest 10 for problem C.

E test case 12?

Anti

`rand()`

testcase.I used srand(time(0))

Err yes — the C standard

`srand()`

and`rand()`

will only generate integers up to`RAND_MAX = 32767`

. The array size is quite large, and such low-range randomization could be easily countered.I don't know what is worse anti-rand or anti java Arrays.sort tests

My lazy way of solving this:

How about using C++ random

I feel liangliang

Tonight I learnt one thing from C, that one should never try multiply two numbers as large as 1e18... Failed several times for it. qwq

Auto comment: topic has been updated by Akikaze (previous revision, new revision, compare).Anyone passed E without randomisation?

So is problem E just testing that we have read this blog Don't use rand(): a guide to random number generators in C++? Really?

Problem E was only about knowing that rand and random shuffle might fail you.

Wow. So we have to be prepared for THIS type of problems now too? So it's kinda STDforces?

I’ve once heard that it’s a programming competition. And yes, you must know how basic stuff works in your favourite language.

I don't mind. I'm just curious if this exploit-as-a-main-idea-stuff is going to be a trend.

It's like exploiting hashes modulo 2^64: if you are doing it often enough, everybody knows it and it gets rather pointless as an "exploit".

I would even say that my example is far from perfect: hashes modulo 2^64 have advantages (like faster execution), so you may still reasons to gamble

"Do they have tests against it?.."; and here the fix is pretty much one-liner without significant side effects.Wow, mathforces, quickforces, hackforces, stdforces...

You guys just never run out of ways to complain about contests.

delayforces, isitratedforces, forcedforces, damnforces, unratedforces, grapeforces, overflowforces, cheatforces, longstatementforces, pupilforces, foolishforces...

Add time(NULL) and random_device not being random to that list.

What is correct structure for F? My first thoutgh is segment tree for each prime with add on segment and sum on segment. But then I realize that segment tree can't do that from my understanding.

That is entirely possible with lazy segment tree, but it uses too much memory.

I had a segment tree storing the product of values in an interval, and a segment tree for every prime telling if the prime exists on the interval. The second type of segment trees just use

`vector<bool>`

, so they don't use too much memory.Answer to every query is just product of numbers in the interval * (p-1 / p) for every prime p that has at least one appearance on the interval. The division is of course modular division.

In total this is

O(q*log(n) * (log(n) +cp)), wherecpis the amount of primes below 300This was quite annoying to fit in time limit however, since I don't know how to write a lazy interval multiplication segtree without taking modpow log(n) times. TLE'd once but some changes passed pretests, taking around 3s

You can make things easier by noticing that there are 62 primes below 300, so you can store a single

long longwith a bitmask of primes available, and then have a single segment tree for all primes and do all updates/queries with bitwise operations.Thanks.

One segment tree for product with range multiplication and the second one with bitsets for primes in range.

Segment tree got TLE with this idea. But BIT passed pretests. :(

Now everybody knows who is the author of problem A. Of course, it's GreenGrape ;)

Problem C Largest power of k in n!

Yeah，I thought of the idea too, But I have not done that problem....sadT_T

What was pretest 5 in C ?

what is wrong with my solution on C? 49728844

Try this.

`9 36`

.The answer should be`2`

.I got that :( f *= f; always create a copy of f then multiply it in the loop. it should be like : f *= copy_f;

20 minutes per problem? I want to think in deeper way, not just to be the fast-solving machine :( Why codeforces is pushing participants(in terms of time) so hard?

noob

Don't insult, playboy. FYI I prepassed ABCDE in this contest.

pro

FYI i dont give shit

C was gay af

what would be the ans in test case in problem C: 5 100?

0I_hate_greengrape

I love GreenGrape. His problems are very beautiful.

NOOOOOOOO, all his problems are from clay. Mathematical clay.

The best. I hate greengrape, and now i start hate all other people))

Wow what the fuck is wrong with those people bashing the authors for including anti rand() tests in pretest? If they weren't kind enough to make those pretests for you then surely someone would hack you in like 5 minutes. Do you guys seriously expect the authors to publicly announce

`Hurr durr just saying rand() is weak you should not use that but this problem is definitely not about random`

?Maybe next time try to actually appreciate the knowledge you gained in contests.

salty

omfg fuck author rand() gave me WA on contest noob tests my code best >:(((

First time I actually enjoyed a GreenGrape contest.

dissapointed with the contest overall but the setters are some weebs so what to expect

Found a perfect place for you to meet people of your kind :o

sorry noob i dont get it

You will get it once you achieve something other than trolling for fake internet attention haha cheers ;)

how can attention be fake? and who said I am trolling? I generally think anime is bad cheers ;); ) ;)omg im cool kid;);):)

Yup! You are a "cool fool"

omg i use big words guys

I think intersection enjoyed this contest!

Me too.

how could you enjoy such a bad contest? it was so poorly made i am legitimately starting to wonder if it was a bad joke being played on us.

turns out rand() has max value 32768 on CF... rip master

For those of you who are looking for a good and clear randomization implementation 49733774 Correct me if I'm wrong.

Thank you Akikaze GreenGrape _kun_ neal

WA#108 E... How to know did it fall due chance 1.86185·10

^{ - 9}?)I failed that too. It should be some hacks regrading std::random_device. I saw lots of submission failing 108 are using std::random_device.

That's because the output sequence of

`std::random_device`

on Codeforces is deterministic, check this.By the way, you are using

`std::random_device`

in wrong way, check this.Yeah, I failed on that test case too.

first impression is last impression. great round!

NO!!!! WHY????

rank 2 to rank 128...

Found you! Original rank 1 (8089 points):

What is wrong with this code.

`flag`

might exceed the range of lld and without fortune it can be in range [0,n- 1] again.Thanks!

If you have a sufficiently big prime (say, greater than

`5e9`

),`flag`

will overflow during your`while(n / flag > 0)`

cycle.Thanks!

Hacks on RANDOM-NUMBER-GENERATOR??!! That's pure evil!!

Today I learned that pure evil is less than 2

^{32}. The funny thing is that random_device is deterministic on codeforces.Auto comment: topic has been updated by Akikaze (previous revision, new revision, compare).Why does using long double instead of long long worked for passing test case 10 in Q.C ?

Even long long can have overflow issues dealing with big primes, something like 1e10 or so. 1e10 * 1e10 makes number even bigger than long long limit.

why my Test Case 17 is failing: Problem B @Akikaze

Test: #17, time: 0 ms., memory: 140 KB, exit code: 0, checker exit code: 1, verdict: WRONG_ANSWER Input

69 9 5

-7 10 7 3 8 -9 9 -6 -5 -1 6 7 -3 10 2 3 -10 3 1 -7 -9 -10 7 2 -10 -7 -5 -5 -8 -7 4 3 10 -7 -8 7 4 6 -5 -6 8 -7 6 -5 -1 -4 0 -3 1 -2 -8 -3 -4 9 8 5 5 -5 -4 10 6 -6 -2 4 -6 -6 -3 -3 0

Output

136

12 27 41 52

Answer

136

13 32 47 57

Checker Log

wrong answer the sum of beauty in contestant's partition does not match with contestant's answer: expected sum = 136, found 130

you are using the least in "bigger" numbers for several times. i got wrong on this test ,too. you should use a flag not to use it more.

Hello codeforces, I want some advice about my sysfailed code in problem E.

https://codeforces.com/contest/1114/submission/49736873 https://codeforces.com/contest/1114/submission/49736886

the only diffrenece between two codes is random function. the one with (rand()<<15)|rand() fails at test 101, but (rand()<<16)|rand() successfully passes all cases. I thought that if cpp rand() generates [0,32767] uniformly, then (rand()<<15)|rand() can generate [0,2^30] uniformly, but the result says it isn't.

Could anybody solve my curiosity? Thanks in advance.

rand()<<15|rand() does generate [0,2^30] uniformly.

I think that test 101 is an anti-test for rand(time(0)), or in other words all values of time(0) that start from somewhere around the end of the contest until a few hours after that, which is around 10800 values for 3 hours, so any code that uses srand(time(0)) and was judged during that time will fail, resubmitting should get AC.

rand()<<16|rand() most likely works because test 101 was based on rand()<<15|rand(), and no similar test was based on rand()<<16|rand().

All of what I said is might not be true, but I couldn't think of any other explanation.

Yeah, that's right.

I did hacked rand()<<15|rand() and srand(time(0)); during the contest, and I generated 50000 values.

https://codeforces.com/contest/1114/hacks/536367/test

Apparently, my this submission got WA on test 101 in contest time and now the same solution is getting AC.

WA Submission

AC Submission (added an extra space before the last line because they weren't allowing me to submit the same code twice).

AC submission doesn't have the line

`x ^= 16153382;`

.`rand()`

is a bad random number generator in general, and using it multiple times actually makes it worse. Also,`rand()`

on CF gives atmost 2^{15}- 1 anyway, so the lines`x &= (1 << 15) - 1`

and`y &= (1 << 15) - 1`

don't have any meaning.May be it's not the most ideal random number generator. But that's not the point. The point is I should get consistent verdicts if I submit the same code repeatedly. And it appears that basically using

`srand(time(0));`

is what caused me that WA, which is frustrating because many other contestants also used it and got AC.What will be the output of this test case for D:

5

6 7 6 8 6

It's 3. My previous wrong solution was printing 2 for this test, because it wasn't take in consedirstion that the chosen start is unchangable, so it proceed your example like following:

7 -> 6

8 -> 6

But the correct process is:

If we choose the index 2 (with number 7) as a start, then we will change it to 6, so the array will be: 6 6 6 8 6, then we connot change the index 2, so the array should become: 8 8 8 8 6, then: 6 6 6 6 6, so the answer is 3.

Thanks a lot! I too misunderstood the question. :D

Wow, cool song

alright, this is enough. i have so many times expressed my concern about programming problems being wrongfully, but intentionally mixed with math. problem C was a nightmare because it had useless math. why do you keep making these? mid problem set you think “i can’t make this hard in a challenging way so i’m just going to bombard it with some random useless stuff”? this is not okay.

also, seeing from the editorial you really didn’t care about the whole contest and/or about us either.. it was a joke. i had high hopes but they all fell short.

Loved this contest! Decently prepared and well-balanced. GRAPE ALL THE WAY

Trying to make some rand(time(0)) code fail? Well, I'm not the great fan of that idea, but it can be an option if problemsetter can block every possible code that he can think of. The problem is that it's definitely impossible. If I use "rand() << 16 | rand()" instead of "rand() << 15 | rand()" by mistake, it will still work. If I use "for(int i = 1; i <= 5; i++) val = (val * RAND_MAX + rand()) % (1<<30)", which is my common random number generating code, it will still work too. If you can only make that exact random generating method, then what's the whole point of making those anti-rand tests? At this point, it's totally unfair to make some of the codes fail only by the reason that he used the same random number generator with the problemsetter.

Well, my initial idea was blocking

`srand()`

and its derivatives only. I have thought of`time(0)`

stuff, but then I didn't go on with making such failed, because:However, hacks are here and there. This kind of behaviours was unavoidable, and we still had to include such hacks into systest (tests with indices ≥ 97 were hacks), thus making things more unfair than what I wanted at first.

I keep getting Runtime Error on B :( What could be the problem? I checked the memory capacity, return value, and declared them in the global variables but nothing seems to work!

I think you made some mistake when you print the answer, have a try on this data :

your code has output 4 numbers in the second line, while the correct case should be 3. By the way, I suggest you use

`>`

instead of`>=`

in`myfunc()`

, it seems that c++ requires strictly lower or bigger.Thanks! Got an AC! Hope I don't make mistakes on indexing next time...haha^^;

First time become blue in this round, feeling good ^_^ .

Wonder how to prevent hack of E by random generator

In problem C, I m getting WA in test case 7 . But I m getting right answer in my compiler. but CF compiler is showing another output and giving me WA in test case 7 . I m using gnu g++ 14 . Can anybody have a look at my code ? https://codeforces.com/contest/1114/submission/49753432.

For Problem C where can i read the necessary properties of factorial to understand the logic behind the given editorial?? I cant understand how the problem was simplified to just that. Akikaze

Consider the b-ary representation of

n!. Let it be represented by the digitsd1,d2,d3,d4,d5,d6(I'm considering it consists of 6 digits. It's similar for any no. of digits). Suppose last 3 digits are zero. Then it's decimal representation will benum=d1*b^5+d2*b^4+d3*b^3. The rest terms are not considered because they are zero. Clearly num is divisible by b^3. Here 3 is the maximum power of b that divides n! which is also the no. of trailing zeros. Hence proving the solution. Satisfy yourself with some more examples.Got it man thanks a lot!!

No problem brother. Happy coding!

In problem C the system says that my code is similar xith xb2403/49705111, ciwomuli/49716822, XY_cpp/49725082;That is because C is similar with the problem P3927 and I use the solution which is last modified at 2017-10-15 14:46

can someone tell me why my solution is wrong?

code

Try to get gcd from

a[x] -a[y] for all your selectedxandy, not onlyxand max.Hey,

Thanks for replying

it is still broken...

Code

I think that there is a countertest on pure random_shuffle. (Might be hack?) And sorry, using Euclidean algorithm my first suggestion is useless. (

gcd(a,b) =gcd(a,b+a))You using random_shuffle for shuffling. Since it using

rand() it shuffling only firstRAND_MAXitems which is small. Usestd: :shuffle(begin,end,mt19937) instead.Hi there,

Thanks for pointing it out! Fixed. Appreciated!

Problem C is an interesting maths problem. The idea is to look carefully at the b-ary representation of the number

n!. It is a modification of Legendre's formula. We need to find the largest powerxofbsuch thatb^xdividesn!.Wow 2019_BecameMaster! You seriously lived up to your name.

Wow the contest makers is a group of vietnamese. Does anyone vietnamese in here

In problem B i am getting correct output on test case 5 on my machine but on codeforces i am getting wrong output please help. My code