#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define debug0(x) printf("! %d\n", x);
#define debug1(x, a, b) for(int (ii)=(a);(ii)<(b);(ii++)) printf("%d: %d\n", ii, x[ii]);
#define nono(x, ite) for(__typeof((x).begin()) (ite)=(x).begin();(ite)!=(x).end();(ite++))
typedef long long ll;
const int N = 1e5 + 10;
ll a[N], b[N];
int n;
int main() {
scanf("%d", &n);
for (int i = 1; i <= n; i++) {
scanf("%I64d%I64d", a + i, b + i);
}
ll ans = 0;
for (int i = n; i >= 1; i--) {
a[i] = (a[i] + ans) % b[i];
a[i] %= b[i];
ans += (b[i] - a[i]) % b[i];
}
printf("%I64d\n", ans);
return 0;
}
./Main.cpp: In function ‘int main()’:
./Main.cpp:23:37: warning: format ‘%d’ expects argument of type ‘int*’, but argument 2 has type ‘ll* {aka long long int*}’ [-Wformat=]
scanf("%I64d%I64d", a + i, b + i);
^
./Main.cpp:23:37: warning: format ‘%d’ expects argument of type ‘int*’, but argument 3 has type ‘ll* {aka long long int*}’ [-Wformat=]
./Main.cpp:31:24: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘ll {aka long long int}’ [-Wformat=]
printf("%I64d\n", ans);
^
./Main.cpp:21:18: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d", &n);
^
./Main.cpp:23:38: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%I64d%I64d", a + i, b + i);
^