Advertisement
Niloy007

A Cf

Mar 26th, 2020
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.41 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5.     int t, a, b, result = 0;
  6.     cin >> t;
  7.     while(t--) {
  8.         cin >> a >> b;
  9.         if(a < b) {
  10.             result = b - a;
  11.         } else {
  12.             int c = a % b;
  13.             if(c == 0) {
  14.                 result = c;
  15.             } else {
  16.                 result = b - c;
  17.             }
  18.         }
  19.         cout << result << "\n";
  20.     }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement