Блог пользователя dakshgarg

Автор dakshgarg, история, 4 года назад, По-английски

We invite you to participate in CodeChef’s Inferno Numero IIT BHU, running this Sunday, 3rd January, from 20:00 pm to 22:00 pm IST. The contest features 6 problems and is 2 hours long.

The Contest is organized by team SPYB!TS IIT BHU.

This is a coding contest based on algorithms, number theory, data structures and problem solving.

Here is the problemsetting panel:
Setters: adikrsingh , Gol.D.Roger , dakshgarg
Tester: emperor_gentoo , masteranimax , gaddopur_coder

Good luck and have fun!

  • Проголосовать: нравится
  • +55
  • Проголосовать: не нравится

»
4 года назад, # |
  Проголосовать: нравится +8 Проголосовать: не нравится

What would be the Prizes for the Winners?

Also, is the Round Rated ?

»
4 года назад, # |
Rev. 2   Проголосовать: нравится 0 Проголосовать: не нравится

In this problem Illuminated Boxes I simply printed (n*m) /gcd(n, m) and it got accepted. I reached at this point mostly by intuition but couldn't prove it. Can anyone who solved this problem share the proof uwi, nuip, EnEm, gupta_samarth, TheAnshul ?

  • »
    »
    4 года назад, # ^ |
      Проголосовать: нравится +10 Проголосовать: не нравится

    Assume WLOG $$$n \geq m$$$.

    If we plot the points $$$[0,n-1]$$$ in the x-axis, we can see that the laser will strike the points between them and for every two consecutive points, it will cross exactly $$$m$$$ boxes.

    Every striking point box will be different ( Otherwise the laser retracing it's path, which is not possible ).

    So we only need to find the number of distinct points strikes in the range $$$[0,n-1]$$$, times $$$m$$$.

    That is exactly equal to $$$\dfrac{n\times m}{gcd(n,m)}$$$.

  • »
    »
    4 года назад, # ^ |
      Проголосовать: нравится +28 Проголосовать: не нравится

    Being a LGM doesn't mean you will go on tagging every person rated lower than you :P

»
4 года назад, # |
  Проголосовать: нравится +4 Проголосовать: не нравится

How to solve problem: WIN IT? any editorial Link?

  • »
    »
    4 года назад, # ^ |
    Rev. 4   Проголосовать: нравится +13 Проголосовать: не нравится

    I didn't solve it in contest but I do have a solution,

    Since the number of distinct primes is atmost 10, you can create 10 range-query trees. And each number will be stored as a product of prime factors $$$p_1^a,p_2^b\dots$$$

    You can update all the primes factors in $$$O(10\log A_i)$$$, and for each query, use these lemma to answer them

    For prime number $$$a,b$$$

    $$$\phi(a^k) = a^k - a^{k-1}$$$

    $$$\phi(a\times b) = \phi(a)\times \phi(b)$$$

    You'd likely need coordinate compression in this, and pre calculated Sieve for factorization in $$$O(\log n)$$$

    This was my idea, though I would like to know if there is any cleaner and efficient implementation to this.

  • »
    »
    4 года назад, # ^ |
      Проголосовать: нравится +3 Проголосовать: не нравится
  • »
    »
    4 года назад, # ^ |
    Rev. 2   Проголосовать: нравится +9 Проголосовать: не нравится

    The idea was to somehow calculate the power of all the primes in $$$l$$$ to $$$r$$$ for $$$2^{nd}$$$ query and also it should be convenient to update when we change the value for the $$$1^{st}$$$ query. Because the number of primes at any moment is less than 10 so we can maintain separate Fenwick tree for each prime. Now that we have the power of each prime in multiplication from $$$l$$$ to $$$r$$$ we can use the formula

    $$$ \phi (n) = p_{1}^{a_{1}} . (1 - \frac{1}{p_{1}}) . p_{2}^{a_{2}} . (1 - \frac{1}{p_{2}}) \cdots p_{k}^{a_{k}} . (1 - \frac{1}{p_{k}}) $$$

    where $$$n = p_{1}^{a_{1}} . p_{2}^{a_{2}} \cdots p_{k}^{a_{k}}$$$.

    Also, don't forget to update the list of those 10 primes for Fenwick Tree as they get changed so once the sum of powers for any prime overall $$$n$$$ become 0 remove that prime. I made two wrong submissions because of this mistake.

    Here is my AC code.