Skip to content

Commit 173adc8

Browse files
committed
fix some bug
1 parent 18c9519 commit 173adc8

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

mathematics/basic.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ void exgcd(LL a, LL b, LL &g, LL &x, LL &y) {
5555
LL mod_inv(LL a, LL m) {
5656
LL d, x, y;
5757
exgcd(a, m, d, x, y);
58-
return d == 1 ? (x % + m) % m : -1;
58+
return d == 1 ? (x % m + m) % m : -1;
5959
}
6060

6161
//ax + by = c,x >= 0, x is minimum

mathematics/congruence-equations.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
#include "basic.hpp"
22

33
// 中国剩余定理, 要求m[i]互质
4-
// x = a[i] (mod m[i]) (0 <= i < n)
4+
// x = c[i] (mod m[i]) (0 <= i < n)
55
LL crt(int n, LL *c, LL *m) {
66
LL M = 1, ans = 0;
77
for (int i = 0; i < n; ++i) M *= m[i];
88
for (int i = 0; i < n; ++i) {
99
LL x, y, g, tm = M / m[i];
1010
exgcd(tm, m[i], g, x, y);
11-
ans = (ans + tm * x * a[i] % M) % M;
11+
ans = (ans + tm * x * c[i] % M) % M;
1212
}
1313
return (ans + M) % M;
1414
}

mathematics/prime.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ struct Primality {
77
if (n <= 1) return false;
88
if (n <= 3) return true;
99
if (~n & 1) return false;
10-
const int u[] = {2,325,9375,28178,450775,9780504,1795265022,0};
10+
const int u[] = {2,3,5,7,325,9375,28178,450775,9780504,1795265022,0};
1111
LL e = n - 1, a, c = 0; // 原理:http://miller-rabin.appspot.com/
1212
while (~e & 1) e >>= 1, ++c;
1313
for (int i = 0; u[i]; ++i) {

0 commit comments

Comments
 (0)