Hello, Codeforces!
I am the writer of the problems.
This blog is invitation to SpecialForces
Previous contest: Mathforces
You will have 5 problems in 120 minutes.
Please register and join the contest.
I bet you will like the contest.
Best of luck for everyone!
Contest starts...
Is it rated?
No
Auto comment: topic has been updated by O--O (previous revision, new revision, compare).
Did you like the contest?
yes, but I've met the third task here
In B 1000ms TL and input of 1e6 which is too much for scripting languages to read.
What do you mean? The time limit seemed reasonable
I think it is possible to make constraints weaker so that it still surely doesn't allow to pass inefficient solutions. The problems is that scripting languages (e.g. Perl) can't even read 1e6 numbers in 1000 ms. I think usually it is OK 5e5 and 2 sec TL, or 1e6 and 4 sec TL.
How to solve last problem
Let $$$e(p)$$$ be exponent of prime $$$p$$$ in $$$f(x)$$$, where $$$f(x) = 1! * 2! * 3! ... * x!$$$.
Imagine extracting out single $$$p$$$ from $$$p! , (2p)!, (3p)! ...((x/p)p)!$$$ from $$$f(x)$$$, this would contribute: $$$(x/p)(x+1) - p(x/p)((x/p) + 1)/2$$$ powers of $$$p$$$.
But still you can extract $$$p's$$$ from $$$p^{2}!, (2p^{2})!, (3p^{2})! ...((x/p^{2})p^{2})!$$$, this would contribute: $$$(x/p^{2})(x+1) - p^{2}(x/p^{2})((x/p^{2}) + 1)/2$$$ powers of $$$p$$$.
Again you can extract more $$$p's$$$ from $$$p^{3}!, (2p^{3})!, (3p^{3})! ...((x/p^{3})p^{3})!$$$, this would contribute: $$$(x/p^{3})(x+1) - p^{3}(x/p^{3})((x/p^{3}) + 1)/2$$$ powers of $$$p$$$.
And so on..
So, you gotta continue summing up till $$$\lceil log_{p}(1e^{9}) \rceil$$$ iterations. That's pretty small!
Complexity: $$$O(t\lceil log_{5}N \rceil)$$$, where $$$t$$$ are no. of testcases.
Answer will be the exponent of $$$5$$$ in $$$f(x)$$$. (Of course)
Hi please can you explain more about contribution part? I am unable to get how you got that formula.
Highest power of a prime $$$p$$$ which divides $$$n!$$$ is $$$\frac{n - sum(n)}{p - 1}$$$. Here $$$sum(n)$$$ is the sum of digits of $$$n$$$ in base $$$p$$$. You need to find the summation of this over $$$[a,b]$$$ for $$$p = 5$$$.
Should i learn this formula or is there any way to derive this? I am unable to get it.
I got this off of stackexchange. https://math.stackexchange.com/questions/141196/highest-power-of-a-prime-p-dividing-n
Short and sweet contest :)
Did C's intended solution use Binary Exponentiation or the Pisano Period? The latter seems much more elegant to me.
make this comment most disliked on codeforces
D can be solved in $$$O(n)$$$ time obviously.
Writing the comment to save the post so I can give the contest later
There is a "star" symbol next to the upvote/downvote. By clicking on it the blog will be added to your favorite blogs and can be viewed later from the favorites tab in ur profile.