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
|
/*
2 7
3 5
*/
import java.io.FileInputStream;
public class Main {
static int a1,a2,b1,b2;
public static void main(String[] args) throws Exception {
Scanner sc = new Scanner(System.in);
a1 = sc.nextInt();
a2 = sc.nextInt();
b1 = sc.nextInt();
b2 = sc.nextInt();
int a = (a1*b2) + (b1 * a2);
int b = a2 * b2;
int c = div(a,b);
int x = a/c;
int y = b/c;
System.out.println(x + " " + y);
}
private static int div(int a, int b) {
while(b != 0) {
int x = a%b;
a = b;
b = x;
}
return a;
}
}
http://colorscripter.com/info#e" target="_blank" style="color:#4f4f4ftext-decoration:none">Colored by Color Scripter
|
'it > 알고리즘' 카테고리의 다른 글
백준 1516 - 게임 개발 (0) | 2019.12.17 |
---|---|
백준 1260 - DFS와 BFS (0) | 2019.12.17 |
백준 1110 - 더하기 사이클 (0) | 2019.12.17 |
백준 1058 - 친구 (0) | 2019.12.17 |
백준 1012 - 유기농 배추 (0) | 2019.12.17 |