duckladydinh's blog

By duckladydinh, history, 9 years ago, In English

Hi everybody!

I have been working on the following number problem for half a year, but still unable to figure it out. Could someone help me?

PROBLEM: Given n elements a[1], a[2] ... a[n], let A be a set such that:

  1. All element a[1], a[2] ... a[n] belong to A.

  2. If x, y belong to A, GCD(x, y) and LCM(x, y) belong to A.

Task: Given a number x, determine if x belongs to A.

Thank you.

  • Vote: I like it
  • +14
  • Vote: I do not like it

»
9 years ago, # |
  Vote: I like it 0 Vote: I do not like it

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

»
9 years ago, # |
  Vote: I like it +3 Vote: I do not like it

What are the limits (A[i], n)

»
9 years ago, # |
  Vote: I like it 0 Vote: I do not like it

if x is gcd of some a[i], then gcd of all a[i] that x divides a[i] is x if x is lcm of some a[i], then lcm of all a[i] that a[i] divides x is x

  • »
    »
    9 years ago, # ^ |
    Rev. 2   Vote: I like it 0 Vote: I do not like it

    How about the case that x doesn't divide any a[i] or no a[i] divides x like:

    a[1] = 6 = 2 * 3

    a[2] = 15 = 3 * 5

    a[3] = 77 = 11 * 7

    a[4] = 35 = 5 * 7

    gcd(6 , 15) = 3 belongs to A

    gcd(77, 35) = 7 belongs to A

    x = 21 = 3 * 7 belongs to A.

    • »
      »
      »
      9 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      I think gcd case is right.

      But lcm case is hacked by your good test case.

      What about only focusing on the divisor of x, check them through gcd way & exist in a[i] . And then update in the way of bfs, get lcm of current divisor and previous divisor, add new one to the queue. Check whether x is visited.

      • »
        »
        »
        »
        9 years ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        I dunno how to prove it, but it seems ...wrong, because I have tried it. :))

»
9 years ago, # |
  Vote: I like it +3 Vote: I do not like it