diff --git "a/BOJ/Java/src/S3/Boj_1735_\353\266\204\354\210\230\355\225\251.java" "b/BOJ/Java/src/S3/Boj_1735_\353\266\204\354\210\230\355\225\251.java" new file mode 100644 index 00000000..5bfbeaf7 --- /dev/null +++ "b/BOJ/Java/src/S3/Boj_1735_\353\266\204\354\210\230\355\225\251.java" @@ -0,0 +1,39 @@ +package S3; + +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 Boj_1735_분수합 { + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); + StringBuilder sb = new StringBuilder(); + StringTokenizer st = new StringTokenizer(br.readLine()); + int A = Integer.parseInt(st.nextToken()); + int B = Integer.parseInt(st.nextToken()); + + st = new StringTokenizer(br.readLine()); + int C = Integer.parseInt(st.nextToken()); + int D = Integer.parseInt(st.nextToken()); + + A = A * D + C * B; + B = B * D; + + C = A; + D = B; + + while (D > 0) { + int temp = D; + D = C % D; + C = temp; + } + + sb.append(A / C).append(' ').append(B / C); + bw.write(sb.toString()); + bw.flush(); + } +}