Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
283 B
1
Indexable
Never
#include <iostream>
using namespace std;
int main() {
	int a, b, c, d;
	d = 0;
	cin >> c;
	for (int i = 0; i < c; i++){
		cin >> a >> b;
		if (a > b) d = (a / b + 1) * b-a;
		if (a < b) d = b - a;
		else if (a == b || a%b == 0) d = 0;
		cout << d << endl;
		d = 0;
	}
}