fork download
  1. import java.util.*;
  2. public class Main {
  3. public static void main(String[] args) {
  4. Scanner sc = new Scanner(System.in);
  5. int t = sc.nextInt();
  6. while (t-- > 0) {
  7. int a = sc.nextInt();
  8. int b = sc.nextInt();
  9. int count = 0;
  10. if(a % b == 0){
  11. System.out.println(0);
  12. }
  13. else{
  14. while(a % b != 0){
  15. a += 1;
  16. count++;
  17. }
  18. System.out.println(count);
  19. }
  20. }
  21. }
  22. }
Success #stdin #stdout 0.11s 56516KB
stdin
5
10 4
13 9
100 13
123 456
92 46
stdout
2
5
4
333
0