Pages

Sunday, December 12, 2010

On MMOD29 (SPOJ)

Yesterday I solved this problem.
You can find a nice analysis of the solution here.

A Modified Version:
Find the multiplication of all the divisors of (2004)x modulo 29



4 comments:

  1. Let D be the total number of divisors of a number, N = p1^a1 * p2^a2 .... pn^an

    Then D = (a1+1) (a2+1) .... (an+1)

    Multiplication of all divisors,

    M = p1 ^ (a1D/2) * p2 ^ (a2D/2) * .... * pn ^ (anD/2)

    We can use this formula to solve the problem.

    ReplyDelete
  2. nice! :)

    Here is another version of the formula for M:

    if D is even: (N^x is not a square number)
    M = N^(D/2)

    if D is odd: (N^x is a square number)
    M = (N^(D/2))*(sq) [ here, sq = sqrt(N^x) ]

    ReplyDelete
  3. This comment has been removed by the author.

    ReplyDelete