P19790 [GeeksforGeeks] Find x and y in linear equation1334
普及-
题目描述

Given A, B and N. Find x and y that satisfies equation Ax + By = N. If there's no solution print -1 in place of both x and y.
Note: There are Multiple solutions possible. Find the solution where x is minimum. x and y should both be non-negative.

Example 1:
Input:
A = 2, B = 3, N = 7
Output:
2 1
Explanation:
22 + 31 = 7.
Example 2:
Input:
A = 4, B = 2, N = 7
Output:
-1 -1
Explanation:
There's no solution for x and y the equation.

Your Task:
You don't need to read input or print anything. Your task is to complete the function findXandY() which takes 3 Integers A,B and N as input and returns a list of 2 integers with the first integer x and the second being y.

Expected Time Complexity: O(N)
Expected Auxiliary Space: O(1)

Constraints:
1 <= A,B <= 10^{5}
0 <= N <= 10^{5}

输入格式

见题面

输出格式

见题面

样例输入
A = 2, B = 3, N = 7
样例输出
2 1