-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCCC'02S2.java
More file actions
27 lines (24 loc) · 764 Bytes
/
Copy pathCCC'02S2.java
File metadata and controls
27 lines (24 loc) · 764 Bytes
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
import java.util.Scanner;
public class Main {
public static void main (String[]args){
Scanner sc = new Scanner(System.in);
int numInput = sc.nextInt();
int denInput = sc.nextInt();
int remain;
if (numInput % denInput == 0) {
System.out.println(numInput/denInput);
} else {
remain = numInput % denInput;
if ((numInput-remain)/denInput > 0) {
System.out.print((numInput-remain)/denInput + " ");
}
for (int x = 1; x < denInput; x++){
if (remain % x == 0 && denInput % x == 0) {
remain = remain/x;
denInput = denInput/x;
}
}
System.out.println(remain + "/" + denInput);
}
}
}