模板最主要的是自己看得舒服,不会给自己留隐患,调起来比较简单,板子有得是,最主要的是改造出适合你的那一套. ——mzz #include<bits/stdc++.h> #define int long long using namespace std; ; struct Hash_Tablet{ int val,nex,id; }edge[mod<<];],num; int a,b,c,ans; void init(){ memset(first,…
3239: Discrete Logging Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 729 Solved: 485[Submit][Status][Discuss] Description Given a prime P, 2 <= P < 231, an integer B, 2 <= B < P, and an integer N, 2 <= N < P, compute the discrete logar…
题目链接 \(BSGS\)模板题..不会点这里 #include <cstdio> #include <cmath> #include <map> using namespace std; typedef long long ll; int a, b, p; int fast_pow(int n, int k){ //n^k%p int ans = 1; while(k){ if(k & 1) ans = (ll)ans * n % p; n = (ll)n *…
Discrete Logging Time Limit: 5000MS Memory Limit: 65536K Total Submissions: 5577 Accepted: 2494 Description Given a prime P, 2 <= P < 231, an integer B, 2 <= B < P, and an integer N, 1 <= N < P, compute the discrete logarithm of N, b…
本文版权归ljh2000和博客园共有,欢迎转载,但须保留此声明,并给出原文链接,谢谢合作. 本文作者:ljh2000 作者博客:http://www.cnblogs.com/ljh2000-jump/转载请注明出处,侵权必究,保留最终解释权! Description Given a prime P, 2 <= P < 231, an integer B, 2 <= B < P, and an integer N, 1 <= N < P, compute the disc…
$补+写题ing$ 第 1 章 快速幂 序列的第 k 个数 link $solution:$ 板子 A 的 B 次方 link $solution:$ 板子 [NOIP2013] 转圈游戏 link $solution:$ 板子 越狱 link $solution:$ 简单的容斥原理,$m^n-m\times \prod_{i=1}^{n-1} m-1$ 第 2 章 质数 Prime Distance link $solution:$ 先筛掉$[1,\sqrt{R}]$,然后在暴力即可. 质因数…
Discrete Logging Time Limit: 5000MS Memory Limit: 65536K Total Submissions: 5865 Accepted: 2618 Description Given a prime P, 2 <= P < 231, an integer B, 2 <= B < P, and an integer N, 1 <= N < P, compute the discrete logarithm of N, b…
BSGS模板题 代码如下 #include <bits/stdc++.h> using namespace std; typedef long long LL; LL fpow(LL a, LL b, LL c) { LL ret = 1 % c; for (; b; b >>= 1, a = a * a % c) { if (b & 1) { ret = ret * a % c; } } return ret; } LL bsgs(LL a, LL b, LL p) {…