import java.util.Scanner;
public class Main {
public static void main(String[] args){
Scanner scanner = new Scanner(System.in);
int a = scanner.nextInt(); int b = scanner.nextInt(); int c = scanner.nextInt();
int d = scanner.nextInt(); int e = scanner.nextInt(); int f = scanner.nextInt();
for(int x = -999; x <= 999; x++) {
for(int y = -999; y <= 999; y++) {
if((a*x+b*y==c) && (d*x+e*y==f)){
System.out.print(x+" "+y);
break;
}
}
}
}
}
브루트 포스 알고리즘이다.
for문과 if문을 이용하여 모든 경우의 수를 판별한다.
'Algorithm > Baekjoon' 카테고리의 다른 글
[백준_JAVA_알고리즘] 2839 설탕 배달 (1) | 2024.02.03 |
---|---|
[백준_JAVA_알고리즘] 1436 영화감독 숌 (0) | 2024.02.02 |
[백준_JAVA_알고리즘] 2231 분해합 (0) | 2024.02.02 |
[백준_JAVA_알고리즘] 2798 블랙잭 (0) | 2024.02.02 |
[백준_JAVA_알고리즘] 24313 알고리즘 수업 - 점근적 표기 1 (0) | 2024.02.01 |