{"id":"f4dbb74a-09fc-454d-9010-56c14b57ecf7","name":"Linear Diophantine Equation","description":"You have been given three Integers a, b and k. you need to find an integral solution of x and y such that a*x + b*y= k * gcd(a,b). \r\n\r\nIt can be proven that solution always exist.","inputFormat":"The first line contains 3 integer a, b and k.","outputFormat":"output integral value of x and y in a single line.","constraints":"1 <= a, b, k <= 10^6","sampleCode":{"cpp":{"code":""},"java":{"code":"import java.util.Scanner;\r\n\r\npublic class Main {\r\n public static void main(String[] args) {\r\n\t\tScanner scn = new Scanner(System.in);\r\n\t\tint a = scn.nextInt();\r\n\t\tint b = scn.nextInt();\r\n int k = scn.nextInt();\r\n \r\n\t\t\r\n\t}\r\n\r\n\r\n}"},"ruby":{"code":""},"python":{"code":""},"javascript":{"code":""}},"points":10,"difficulty":"medium","sampleInput":"3 5 8","sampleOutput":"16 -8\r\n","questionVideo":"https://www.youtube.com/embed/hl3JWn1loiI","hints":[],"associated":[],"solutionSeen":false,"tags":[],"meta":{"path":[{"id":0,"name":"home"},{"id":"0c54b191-7b99-4f2c-acb3-e7f2ec748b2a","name":"Data Structures and Algorithms","slug":"data-structures-and-algorithms","type":0},{"id":"086949fa-3c5e-40c6-8a9c-f9be4b400318","name":"Number Theory For Experts","slug":"number-theory-for-experts","type":0},{"id":"494d08e9-b9e3-459b-9395-9a9de36aa28c","name":"Linear Diophantine Equation","slug":"linear-diophantine-equation","type":1}],"next":{"id":"4940a5f2-3a1e-4899-a580-63aa0c1bc2c9","name":"Eulers Totient Function","type":1,"slug":"eulers-totient-function"},"prev":{"id":"5d1351ed-560a-4694-92f6-1e52560161ac","name":"Extended Euclidean Algorithm","type":1,"slug":"extended-euclidean-algorithm"}}}

Linear Diophantine Equation

You have been given three Integers a, b and k. you need to find an integral solution of x and y such that a*x + b*y= k * gcd(a,b). It can be proven that solution always exist.

{"id":"f4dbb74a-09fc-454d-9010-56c14b57ecf7","name":"Linear Diophantine Equation","description":"You have been given three Integers a, b and k. you need to find an integral solution of x and y such that a*x + b*y= k * gcd(a,b). \r\n\r\nIt can be proven that solution always exist.","inputFormat":"The first line contains 3 integer a, b and k.","outputFormat":"output integral value of x and y in a single line.","constraints":"1 <= a, b, k <= 10^6","sampleCode":{"cpp":{"code":""},"java":{"code":"import java.util.Scanner;\r\n\r\npublic class Main {\r\n public static void main(String[] args) {\r\n\t\tScanner scn = new Scanner(System.in);\r\n\t\tint a = scn.nextInt();\r\n\t\tint b = scn.nextInt();\r\n int k = scn.nextInt();\r\n \r\n\t\t\r\n\t}\r\n\r\n\r\n}"},"ruby":{"code":""},"python":{"code":""},"javascript":{"code":""}},"points":10,"difficulty":"medium","sampleInput":"3 5 8","sampleOutput":"16 -8\r\n","questionVideo":"https://www.youtube.com/embed/hl3JWn1loiI","hints":[],"associated":[],"solutionSeen":false,"tags":[],"meta":{"path":[{"id":0,"name":"home"},{"id":"0c54b191-7b99-4f2c-acb3-e7f2ec748b2a","name":"Data Structures and Algorithms","slug":"data-structures-and-algorithms","type":0},{"id":"086949fa-3c5e-40c6-8a9c-f9be4b400318","name":"Number Theory For Experts","slug":"number-theory-for-experts","type":0},{"id":"494d08e9-b9e3-459b-9395-9a9de36aa28c","name":"Linear Diophantine Equation","slug":"linear-diophantine-equation","type":1}],"next":{"id":"4940a5f2-3a1e-4899-a580-63aa0c1bc2c9","name":"Eulers Totient Function","type":1,"slug":"eulers-totient-function"},"prev":{"id":"5d1351ed-560a-4694-92f6-1e52560161ac","name":"Extended Euclidean Algorithm","type":1,"slug":"extended-euclidean-algorithm"}}}
plane

Editor


Loading...

Linear Diophantine Equation

medium

You have been given three Integers a, b and k. you need to find an integral solution of x and y such that a*x + b*y= k * gcd(a,b). It can be proven that solution always exist.

Constraints

1 <= a, b, k <= 10^6

Format

Input

The first line contains 3 integer a, b and k.

Output

output integral value of x and y in a single line.

Example

Sample Input

3 5 8

Sample Output

16 -8

Question Video

Discussions

Show Discussion

Related Resources

related resources

Turning Off Zen Mode