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

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

Warm greetings,

Newton School cordially invites you to be a part of our monthly coding contest. The challenge will go live on 30th June 2021 at 9 PM IST. The contest will have our dearest characters from FRIENDS!

Registration Link: Newton's Coding Challenge

You will be given 6 problems and 150 minutes to solve them.

The problems are written and prepared by aniket9465 and swapnil07.

We would also like to thank:

  • gkapatia for co-ordinating the contest.
  • jiraya_ and ak532 for the valuable feedback throughout.

    Highlights of contest:

    1. The Prize Money for the top 5 performers are as follows:
      • First Prize: ₹10,000
      • Second Prize: ₹5,000
      • Third Prize: ₹2,500
      • Fourth Prize: ₹1,500
      • Fifth Prize: ₹1,000
    2. ₹100 Amazon gift vouchers to the top 50 participants.
    3. ₹100 Amazon gift vouchers to 50 randomly selected participants ranked between 51-500.

    Note: Prizes are for Indian Participants only. Participants from other countries can opt to receive an Amazon Gift voucher in INR.

    We hope you like the contest! Hope to see you all at the leaderboard! :)

    Also, we have opened the problems from previous coding contests for practice.

    Thanks, have a great day ahead.

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

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

    Auto comment: topic has been updated by swapnil07 (previous revision, new revision, compare).

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

    what is the Stream/ Specialization section of the reg. part??

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

    .

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

    "Something Wrong" on Questions tab.

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

    In E do we use Dirichlet convolution to find the number of co-prime pairs less than $$$\displaystyle \frac{L}{X}$$$ or is there an easier way to go about it?
    My idea was to calculate $$$\mu(i)$$$ using dirichlet convolution and then find the number of coprime pairs by $$$\displaystyle\sum_{i=1}^N \mu(i)(\frac{N}{i})^2$$$ where $$$\displaystyle N=\frac{L}{X}$$$. This would be an $$$\displaystyle\mathcal{O}((\frac{L}{X})^{\frac{2}{3}})$$$ solution.

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

    1e9/1e18 boring math problem spam with occasionally sub-par samples, and copied problems. (Also, sum of Euler totient till 1e9? Really? Is this Project Euler? Also easily googleable BTW)

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

    In D what's the approach or there was a short trick ????

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

    In problem C, this solution was getting WA on 3 cases, could anyone help out?

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

      wait what? My solution was pretty much the same yet it got AC. if(a>=b) then Chandler wins else Joey wins. How come your solution doesn't work

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

        Yes, that's what confuses me. The entire duration I tried to figure this out, even wrote a brute-force checker but didn't find the error. swapnil07 Can you please look into this, any bug ? My username is adityatrivedi25. Thanks

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

    What was the simpler solution for problem D.

    My solution used Dp[0,a+b]=0 and Dp[1,a+b-1]=x, and made equations for other states in terms of x. Had to use matrix exponentiation for solving.

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

      $$$dp[i][j]=i*j$$$ lol

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

      Problem $$$D$$$ already exists by the name Gamblers Ruin. The same problem has already been discussed here. Answer to the porblem is just $$$a \cdot o$$$.

      The proof is really hard it seems.

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

        Do you mean to say that you observed it just by looking at the recurrence? or did you do the hard proof?

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

          No, I knew about Gamblers Ruin prior to the contest. Otherwise, I don't think I could have solved this challenge on my own.

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

        Also, problems $$$A$$$ and $$$B$$$ are just bad. Problem $$$E$$$ already exists in multiple sites. For example here. And, now I know that problem $$$F$$$ is the exact copy of this. Although I liked solving it during the contest as I didn't have any prior knowledge of the existing problem. I solved it using digit dp along with plug dp.

        I don't know how this contest has prizes with these problems.

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

      Let $$$N = A+O$$$. $$$dp[i]$$$ represents the expected number of moves given that there are $$$i$$$ apples currently (and as a result $$$N-i$$$ oranges).

      $$$ dp[i] = 1 + (dp[i-1] + dp[i+1])/2\\ \implies dp[i+1] - dp[i] = dp[i] - dp[i-1] - 2 $$$

      Hence, the difference between consecutive items in the DP form an AP with common difference $$$-2$$$. Let's say the first term of this AP is $$$d$$$. Also, as a base case $$$dp[0] = dp[N] = 0$$$. This means that the sum of all adjacent differences in the DP, and so this AP, is 0.

      Using the expression for the sum of an AP, we get $$$N(d-N+1) = 0$$$, and hence $$$d = N-1$$$.

      Our required answer is $$$dp[A]$$$, which the the sum of first $$$A$$$ terms of the above AP. You can see that it reduces to $$$A*(N-A)$$$.

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

    For D, should we not have the following recurrence $$$dp(x,y) = 1 + \left(\frac{x}{x+y}\right)dp(x-1,y+1) + \left(\frac{y}{x+y}\right)dp(x + 1,y - 1)$$$