Блог пользователя Utkarsh.25dec

Автор Utkarsh.25dec, 2 года назад, По-английски

We invite you to participate in CodeChef’s Starters 62, this Wednesday, 26th October, rated till 6-stars participants (ie. for users with rating < 2500).

Time: 8 PM — 11:00 PM IST

Joining us on the problem setting panel are:

Written editorials will be available for all on discuss.codechef.com. Pro users can find the editorials directly on the problem pages after the contest.

The video editorials of the problems will be available for all users for 1 day as soon as the contest ends, after which they will be available only to Pro users.

Also, if you have some original and engaging problem ideas, and you’re interested in them being used in CodeChef's contests, you can share them here.

Hope to see you participating. Good Luck!

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

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

Note:there is an interactive problem in this round.

If you are unfamiliar with interaction problems,you can read the guide for interactive problems here.

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

Problem PYTHAGORAS

largest odd divisor of N does not exceed 10^5

I believe that this condition is not satisfied in some tests. Can anybody from admins check this?

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

Can Any Body Explain the logic of Pythagoras Pair

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

    Sum of Squares theorem states that a number $$$N$$$ can always be represented as the sum of two squares as long as there is no prime $$$p$$$ in $$$N$$$'s factorization such that $$$p \equiv 3$$$ $$$(mod$$$ $$$4)$$$ and its exponent is odd.

    Because of the constraint on $$$N$$$, notice that it means that $$$N$$$ always takes the form of $$$x*y$$$, where $$$x$$$ is a power of $$$2$$$ and $$$y$$$ is less than or equal to $$$10^5$$$. Due to the Sum of Squares Theorem mentioned earlier, if $$$y$$$ is possible, then $$$x*y$$$ is possible, and if $$$y$$$ is not possible, then $$$x*y$$$ is also impossible. So it would be nice if we could find the answer for $$$y$$$, and translate that into an answer for $$$x*y$$$. Turns out that we can, since notice that every other power of 2 is a square. If we ensure that $$$x$$$ is a power of $$$4$$$(and thus, a perfect square), $$$y \leq 2*10^5$$$ will hold true.

    As such, we can precalculate the answer for everything from $$$1...2*10^5$$$, and when answering a query of $$$N$$$, we split $$$N$$$ into $$$x*y$$$. Our answer should then be $$$\sqrt{x}*(y_1,y_2)$$$, where $$$y_1$$$ and $$$y_2$$$ are the valid pair(if it exists) for $$$y$$$.