import java.util.Scanner;
public class Main {
public static void main(String[] args) throws Exception {
// 배열 A와 숫자 n을 입력받는다.
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
int b = sc.nextInt();
int c = sc.nextInt();
int d = sc.nextInt();
int e = sc.nextInt();
int f = sc.nextInt();
int x = 0;
int y = 0;
for (int i = -999; i <= 999; i++) {
// 이중 for문을 사용하여 x, y가 -999인 상황부터 999인상황까지 모든 경의우수를 대입한다
for (int j = -999; j <= 999; j++) {
if (((a * i) + (b * j) == c) && ((d * i) + (e * j) == f)) {
x = i;
y = j;
}
}
}
System.out.print(x + " " + y);
sc.close();
}
}
아이디어 :
1. 입력 가능한 모든 경의의수를 대입하여 조건을 만족하도록 한다.
'java' 카테고리의 다른 글
| 백준 2751 수 정렬2 자바 java (0) | 2024.01.18 |
|---|---|
| 백준 1436 영화감독 숲 자바 java (0) | 2024.01.16 |
| 백준 2231 분해합 java 자바 (0) | 2024.01.16 |
| 백준 2789 블랙잭 java 자바 (0) | 2024.01.16 |
| 백준 24313 자바 java (1) | 2024.01.15 |