Ad
  • Custom User Avatar

    BigInteger actually has its own gcd method aptly named "gcd"

    x.gcd(y) will return the gcd of x and y

  • Custom User Avatar

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

  • Custom User Avatar

    I advise you to try to figure it out on your own. I think there’s no point in immediately reading the solution or looking at the answers if something doesn’t work out.

    It's better to try solving the problem yourself, and if it doesn’t work, lower the difficulty. If you're a beginner, it might be too early to tackle 4 kyu problems.

    I can explain the solution without any problem, as can anyone else, but it won’t really help you. I'm sure that with time, as you gain experience, you'll be able to solve complex problems independently and efficiently. Good luck!

  • Custom User Avatar

    Could you please explain you code to me? I can't understand it beacause I am a junior developer.

  • Custom User Avatar

    fcurz, I think I made my point

  • Custom User Avatar

    As much as I agree with the general message, we still have to take care of the language on the platform and i need to hide the comment.

  • Custom User Avatar

    This comment has been reported as abusive

  • Custom User Avatar

    you have 3 point, buy two items, now you have 5 points, which is enough to get the last item for free, after which you have no more points available

  • Custom User Avatar
  • Custom User Avatar

    This is the coolest and most clever solution I've seen on this website so far.
    Well Done!

  • Custom User Avatar

    I would totally agree with you if I knew English better. But when I put those words into a translator, they came out with the same meaning

  • Custom User Avatar

    I agree. The description should replace "equidistant" with "evenly spaced", in my opinion. "Equidistant" had me picturing groups where all members were the same distance from each other, which would limit the groups to sizes of 1, 2, or 3.

  • Custom User Avatar

    The thing I lke the most is your gcd function.

  • Custom User Avatar

    What is y[] used for ?

  • Custom User Avatar

    You have two chocolate bars. Each chocolate bar has portraits on it, but not necessarily in the same order. Your goal is to break the second chocolate bar as few times as possible in order to put the portraits in the same order as in the first bar. Each portrait is represented by a number from 1 to n.

    For the example given:

    first bar
    |4|3|2|5|1|

    second bar
    |1|2|5|3|4|

    There are three breaks you have to make in order to assemble the pieces in the correct order. One break between the 1 and 2, one between the 5 and 3, and one between the 3 and 4. That leaves you with the four pieces:

    |1| + |2|5| + |3| + |4|

    which can be rearranged to match the first bar:

    |4| + |3| + |2|5| + |1|

    I hope that makes sense.

  • Loading more items...