#define _CRT_SECURE_NO_WARNINGS #include<iostream> #include<string> #include<cstring> #include<cmath> #include<ctime> #include<algorithm> #include<utility> #include<stack> #include<queue> #include<vector> #include<set> #include<map> #include<unordered_map> using namespace std; #define LL long long const int N = 2e5+ 10; const int M = 200000 + 10; const int P = 1331; const long long mod = 9973; const double PI = acos(-1); int n, m, k; struct matrix { int a[11][11]; matrix() { memset(a, 0, sizeof a); } }t; LL phi(LL x) { LL ans=x; for (int i = 2; i * i <= x; i++) { if (x % i == 0) { ans = ans/ i*(i-1); while (x % i == 0) x /= i; } } if (x > 1) ans = ans/x*(x-1); return ans; } struct matrix mul(struct matrix g, struct matrix h) { struct matrix c; for(int i=0;i<m;i++) for (int j = 0; j < m; j++) { c.a[i][j] = 0; for (int k = 0; k < m; k++) { c.a[i][j] = (c.a[i][j] + g.a[i][k] * h.a[k][j] % mod) % mod; } } return c; } LL f(int b) { struct matrix r=t,ans; for (int i = 0; i < m; i++) ans.a[i][i] = 1; while (b) { if (b & 1) ans = mul(ans, r); b >>= 1; r = mul(r, r); } LL res = 0; for (int i = 0; i < m; i++) res = (res+ans.a[i][i])%mod; return res; } LL quick(LL a, LL b,LL mod) { LL ans = 1; while (b) { if (b & 1) ans = ans * a % mod; b >>= 1; a = a * a % mod; } return ans; } int main() { int T; cin >> T; while (T--) { cin >> n >> m >> k; for (int i = 0; i < m; i++) for (int j = 0; j < m; j++) t.a[i][j] = 1; for (int i = 1; i <= k; i++) { int x, y; cin >> x >> y; x--; y--; t.a[x][y] = 0; t.a[y][x] = 0; } LL ans = 0; for (LL i = 1; i * i <= n; i++) { if (n % i == 0) { ans = (ans + (LL)phi(n / i) * f(i) % mod) % mod; if (i * i != n) ans = (ans + (LL)phi(i) * f(n / i) % mod) % mod; } } cout << ans*quick(n,mod-2,mod)%mod << endl; } return 0; }
减少数据处理量,提高查询效率 (一)使用Limit分页 –从第2个开始查询,每一页10个
select * from user limit 2,10
–从第0个开始查询,每一页10个
SELECT * from user limit 10;
领取资料 (二)使用Mybatis实现分页,核心SQL 1、编…