728x90
320x100
import java.io.*;
import java.util.ArrayList;
import java.util.Scanner;
import java.util.StringTokenizer;
public class Main {
public static void main(String []args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
StringTokenizer st = new StringTokenizer(br.readLine());
int a = Integer.parseInt(st.nextToken());
int b = Integer.parseInt(st.nextToken());
int c = Integer.parseInt(st.nextToken());
long gcd = gcd(a, b);
if(c%gcd != 0) {
System.out.println(-1);
}
else {
int mok = (int) (c/gcd);
long []ret = Excute(a,b);
System.out.println(ret[0] * mok + " " + ret[1] * mok);
}
}
private static long[] Excute(int a, int b) {
long []ret = new long[2];
if(b==0) {
ret[0] = 1;
ret[1] = 0;
return ret;
}
long q = a/b;
long []v = Excute(b, a%b);
ret[0] = v[1];
ret[1] = v[0] - v[1] * q;
return ret;
}
private static long gcd(long a, long b) {
while(b!=0) {
long tmp = a%b;
a = b;
b = tmp;
}
return Math.abs(a);
}
}
728x90
반응형
'Baekjoon' 카테고리의 다른 글
[JAVA][Baekjoon] 1850번 최대공약수 🌟🌟 (0) | 2025.01.12 |
---|---|
[JAVA][Baekjoon] 1934번 최소공배수 🌟🌟 (0) | 2025.01.11 |
[JAVA][Baekjoon] 11689번 GCD(n, k) = 1 🌟🌟 (0) | 2025.01.11 |
[JAVA][Baekjoon] 1016번 제곱 ㄴㄴ 수 🌟🌟🌟🌟 (0) | 2025.01.10 |
[JAVA][Baekjoon] 1747번 소수&팰린드롬 🌟🌟 (0) | 2025.01.10 |