没人吗……?
by DiTeXy @ 2018-10-14 10:27:40
if(M>=1000000000000000000LL) break;试试?
by 142857cs @ 2018-11-09 14:46:53
@[黑暗主宰](/space/show?uid=86793)
我开的__int128能过呀
```cpp
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <vector>
#include <map>
#define MAX 0x7fffffff
#define MIN 0x80000000
#define INF 0x3f3f3f3f
#define ll long long
#define int __int128
using namespace std;
inline void read(register int &x){
x = 0; register int f = 1;
register char ch = getchar();
while (!(ch >= '0' && ch <= '9')){ if (ch == '-') f = -1; ch = getchar(); }
while (ch >= '0' && ch <= '9'){ x = x * 10 + ch - '0'; ch = getchar(); }
x *= f;
}
int n, now, lcm;
inline int exgcd(register int a, register int b, register int &x, register int &y){
if (b == 0){ x = 1, y = 0; return a; }
register int ret = exgcd(b, a % b, x, y), tmp = x;
x = y, y = tmp - a / b * y;
return ret;
}
signed main(){
read(n);
register int a, b; read(b), read(a);
lcm = b, now = a;
for (register int i = 1; i < n; i++){
read(b), read(a);
a = ((a - now) % b + b) % b;
register int x, y;
register int g = exgcd(lcm, b, x, y);
register int k = x * (a / g) % b;
now += k * lcm;
lcm = lcm / g * b;
now = (now % lcm + lcm) % lcm;
}
printf("%lld\n", now);
return 0;
}
```
by yy1695651 @ 2018-12-06 13:35:17
考古
by Happynewyear @ 2019-01-13 20:09:21