Sort by

recency

|

7 Discussions

|

  • + 0 comments

    I don't why there is Run Time ERROR (for higher values of a,b,c) even in time complexicity O(n).

    for _ in range(int(input())):
        a,b,c=map(int,input().split())
        x=int(c/(a+(b/a)*b))
        m,n=x,x
        while True:
            if m>0:
                y=(c-a*m)/b
                if y==int(y):
                    print(str(m)+" "+str(int(y)))
                    break
                m-=1
            y=(c-a*n)/b
            if n>0 and y==int(y):
                print(str(n)+" "+str(int(y)))
                break
            n+=1
    
  • + 0 comments

    This is not a geometry exercise

  • + 1 comment

    Hi,

    There seems to be something wrong with this problem :

    The linear diophantine equation a*x+b*y=c hasn't always integer solutions, if no constraint at all is imposed to a, b, and c.

    The following wikipedia article (in french) explains it :

    linear diophantine equation (french)

    Sorry, but the article on Wikipedia is only available in French.

    Best regards

    • + 0 comments

      Is this not resolved by the constraint that a, b, c are all integers?

      "Each line of the subsequent lines contains three space-separated integers describing the respective values of a, b, and c for the query."

  • + 0 comments

    can anybody give some hints?

  • + 4 comments

    I think there is another error in the testcases.

    Testcase 2

    • Item #12
    • Input: 4 1 82
    • Testcase Solution: 19 6 (4*19+6 = 82)
    • Correct Solution: 1 78 (4*1+78 = 82)

    Testcase 3

    • Item #73
    • Input: 30 3 69
    • Testcase Solution: 2 3 (2*30 + 3*3 = 69)
    • Correct Solution: 1 13 (1*30 + 13*3 = 69)
    • + 0 comments

      I second this.

    • + 1 comment

      the point (1,78) is much further from the origin than the point (19,6). Same goes for (2,3) and (1,13).

      • + 1 comment

        Based on the answer, it's the closest to origin; but in the descrption, it clearly says it's the one with minimal x value.

        • + 1 comment

          The first most important is that it's closest to the origin. After that, if there's a tie it goes to minimal x. The important section in the description is this:

          " Find the point closest to the origin that also satisfies the following properties:

          1. x and y are integers.
          2. x is greater than zero.

          If more than one solution exists satisfying 1 and 2, then choose the point in which x is minimal. "

          So for example the point (1,2) and (2,1) are equally close to the origin; if these were both solutions to the equation, (1,2) would be the correct choice. But (1,8) is further away from the origin than (2,3); if these were both solutions to the equation, (2,3) would be the correct choice.

          I hope that helps clarify.

    • + 0 comments

      i think so too..