Ad
  • Default User Avatar
  • Default User Avatar

    I got pretty similar result ~ 3.6s

  • Custom User Avatar
  • Default User Avatar

    theDarkBright, I just ran your solution now (twice) and it ran for 4.7 secs. Maybe server load plays a role. I ran mine also, and it runs in 0.7 secs. So there is still room for improvement. I also don't think my implementation is the most optimal one.

  • Default User Avatar

    lol wish I saw this before I started fixing mine, cause I had the same bug.. (java)

  • Custom User Avatar

    I'm glad you figured it out & liked it.

    TDRS

  • Custom User Avatar

    Got it, and solved. Thanks a lot!

  • Default User Avatar

    The description says:

    A natural number is called k-prime if it has exactly k prime factors, counted with multiplicity.

    4 = 2 * 2 is 2-prime since he has two prime factors (the prime 2 is not unique: 2 has multiplicity 2 since the prime 2 appears 2 times)
    6 = 2 * 3 is 2-prime since he has two prime factors (2 and 3)
    8 = 2 * 2 * 2 is 3-prime since 2 is prime and its multiplicity (= number of times it appears) is 3
    12 = 2 * 2 * 3 is 3-prime since he has 2 prime factors (2 and 3 but 2 appears 2 times)
    48 = 2 * 2 * 2 * 2 * 3 is 5-prime: 2 appears 4 times and 3 once
    Note: 1 is not a prime factor because 1 is not a prime.

  • Custom User Avatar

    prime factors, not unique prime factors

  • Custom User Avatar
    Examples of k-primes:
    k = 2 -> 4, 6, 9, 10, 14, 15, 21, 22, …
    k = 3 -> 8, 12, 18, 20, 27, 28, 30, …
    k = 5 -> 32, 48, 72, 80, 108, 112, …
    

    I don't get what a k-prime is, honestly. If it is 1-inclusive, isn't 6 a 3-prime, and isn't 8 a 2-prime? If it is not 1-inclusive, aren't both 4 and 8 1-primes?
    4: prime factors -> (1,) 2
    6: prime factors -> (1,) 2, 3
    8: prime factors -> (1,) 2

    What does counted with multiplicity mean?

  • Custom User Avatar

    Did you finally debug it? Because I have the exact same issue with Python.
    I pass all sample tests, though.

    HIT! 5
    HIT! 15
    HIT! 2
    HIT! 10
    HIT! 4
    

    The above is my result.

    Alien [17] with [3] health
    Alien [19] with [15] health
    Alien [21] with [2] health
    Alien [23] with [10] health
    Alien [24] with [4] health
    : 36 should equal 34
    

    This is the reference result. So far, I've mostly overshot by 2 points, and always at the first alien to hit. :/
    EDIT: My bad. I didn't read the hit-sequence instruction properly.

  • Custom User Avatar

    Python: Unlike in JS version, generating all the test cases alone took 5.5-6.5 seconds, which leaves us only 6 seconds (in Python 2) or worse, just 4 seconds (in Python 3) to spare after accounting for reference solution. JS version, on the other hand, has 7-8 seconds.

  • Custom User Avatar

    Also, the input range is given. Any good competitive programming participant should be able to judge the required complexity based on the input range ;-)

  • Custom User Avatar

    You need a O(n) to O(log n) solution ;-)

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Loading more items...