Thursday, September 17, 2015

Find Remainder (Mock KICTM UiTM Jasin 2015)

Write a program to find the remainder when two given numbers are divided.

Input and Output

The first line contains an integer T, total number of test cases. Then follow T lines, each line contains two integers A and B. Find remainder when A is divided by B

Constraints
1 <= T <= 1000
1 <=A,B <== 10000


Samples Input
3
1 2
100 200
10 40

Samples Output
1
100
10



 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
import java.util.*;
import java.lang.*;
import java.math.*;

public class Mock4{
   public static void main(String[] args){
      Scanner scan = new Scanner(System.in);
      
      String line =System.getProperty("line.separator");
      scan.useDelimiter(line);
      
      int cases = scan.nextInt();
      
      for(int x=0;x<cases;x++){
         
         String [] get = scan.next().split(" ");

         System.out.println(Integer.parseInt(get[0]) % Integer.parseInt(get[1]));
         
      }
   }
}

No comments:

Post a Comment