-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathsub.java
More file actions
34 lines (31 loc) · 1010 Bytes
/
sub.java
File metadata and controls
34 lines (31 loc) · 1010 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
28
29
30
31
32
33
34
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class subtract {
public static void sub() throws IOException{
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
int input = Integer.parseInt(reader.readLine());
int i=0;
while(i<input){
String[] nums = reader.readLine().split(" ");
int num1 = Integer.parseInt(nums[0]);
int num2 = Integer.parseInt(nums[1]);
int count=0;
while(num1>0 && num2>0){
if(num1>=num2){
count++;
num1=num1 - num2;
}
else {
count++;
num2 = num2 - num1;
}
}
System.out.println(count);
i++;
}
}
public static void main(String[] args) throws IOException{
sub();
}
}