正文
增加 15 行删除 10 行
619 行未改动全部展开62062162262362462562662762815 行未改动644645646647648649650651652653654655656657658659660661662663146 行未改动全部展开619 行未改动全部展开```cpp#include <bits/stdc++.h>#define int long longusing namespace std;int n, a1, a2, m1, m2;int mul(int a, int b, int mod) {int ans = 0;while (b) {if (b & 1) ans = (ans + a) % mod;15 行未改动}signed main() {ios::sync_with_stdio(0);cin.tie(0), cout.tie(0);cin >> n >> m1 >> a1;for (int i = 2; i <= n; i++) {cin >> m2 >> a2;exgcd(m1, m2);int d = __gcd(m1, m2);int k = m2 / d, qwq = (((a2 - a1) / d) % k + k) % k;x = (x % k + k) % k;x = mul(x, qwq, k);a1 += m1 * x;m1 *= k, a1 %= m1;}cout << a1;return 0;}```::::146 行未改动全部展开619 行未改动全部展开62062162262362462562662762815 行未改动644645646647648649650651652653654655656657658659660661662663664665666667668146 行未改动全部展开619 行未改动全部展开```cpp#include <bits/stdc++.h>#define int long longusing namespace std;int n, A, B;int mul(int a, int b, int mod) {int ans = 0;while (b) {if (b & 1) ans = (ans + a) % mod;15 行未改动}signed main() {ios::sync_with_stdio(0);cin.tie(0), cout.tie(0);cin >> n;A = 1, B = 0;for (int i = 1; i <= n; i++) {int a, b;cin >> a >> b;exgcd(A, a);int d = __gcd(A, a);int k = a / d;int qwq = (((B - b) / d) % k + k) % k;x = (x % k + k) % k;x = mul(x, qwq, k);B = B - A * x;A = A / d * a;B %= A;if (B < 0) B += A;}cout << B % A;return 0;}```::::146 行未改动全部展开