☕Language: Java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.StringTokenizer;
public class Main {
public static void main(String[] args) throws IOException {
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = new StringTokenizer(br.readLine(), " ");
int a = Integer.parseInt(st.nextToken());
int b = Integer.parseInt(st.nextToken());
int c = Integer.parseInt(st.nextToken());
int d = Integer.parseInt(st.nextToken());
int e = Integer.parseInt(st.nextToken());
int f = Integer.parseInt(st.nextToken());
bw.write(((c*e - b*f)/(a*e - b*d)) + " " + ((d*c-f*a)/(d*b-e*a)));
bw.flush();
bw.close();
}
}
|
🤔 해설
- 일차 방정식의 해 도출
😮 이 외의 풀이
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.StringTokenizer;
public class Main {
public static void main(String[] args) throws IOException {
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = new StringTokenizer(br.readLine(), " ");
int a = Integer.parseInt(st.nextToken());
int b = Integer.parseInt(st.nextToken());
int c = Integer.parseInt(st.nextToken());
int d = Integer.parseInt(st.nextToken());
int e = Integer.parseInt(st.nextToken());
int f = Integer.parseInt(st.nextToken());
int i = 0;
int j = 0;
Loop:
for(i=-999; i<=999; i++) {
for(j=-999; j<=999; j++) {
if(a*i + b*j == c && d*i + e*j == f) {
break Loop;
}
}
}
bw.write(i + " " + j);
bw.flush();
bw.close();
}
}
|
- x, y에 정해진 범위의 값 대입
🔗 소스 코드
HJ0216/TIL/BOJ
📚 참고 자료
'Computer > Algorithm_Java' 카테고리의 다른 글
[BaekJoon] 2751번 수 정렬하기2 문제풀이 (Success) (0) | 2023.07.29 |
---|---|
[BaekJoon] 2839번 설탕 배달 문제풀이 (Success) (0) | 2023.07.28 |
[BaekJoon] 2798번 블랙잭 문제풀이 (Success) (0) | 2023.07.25 |
[BaekJoon] 11653번 소인수분해 문제풀이 (Success) (0) | 2023.07.24 |
[BaekJoon] 1978번 소수 찾기 문제풀이 (Success) (0) | 2023.07.23 |