随笔分类 -  模板

摘要:1 /* 2 algorithm : High-Precision FFT 3 4 */ 5 #include 6 #include 7 #include 8 #include 9 #define N 200005 10 #define pi acos(-1.0) // PI值 11 using namespace std; 12 st... 阅读全文
posted @ 2016-09-28 21:40 Yan_Bin 阅读(341) 评论(0) 推荐(0) 编辑
摘要:使用唯一素因子分解定理进行: 阅读全文
posted @ 2016-09-04 01:25 Yan_Bin 阅读(681) 评论(0) 推荐(0) 编辑
摘要:有两种计算方式,直接计算或者递推计算: 阅读全文
posted @ 2016-09-03 17:16 Yan_Bin 阅读(160) 评论(0) 推荐(0) 编辑
摘要:通过展示STL中已存在的lowerbound和uppebound函数来展示二分查找。 阅读全文
posted @ 2016-09-02 20:04 Yan_Bin 阅读(127) 评论(0) 推荐(0) 编辑
摘要:这里用一个抛物线求弧长的例子给出Simpson公式的代码: 阅读全文
posted @ 2016-09-02 15:56 Yan_Bin 阅读(1150) 评论(0) 推荐(0) 编辑
摘要:1 #include 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 #define MAXN 9999 // 大数类里面的数组中每个单元的最大正整数 8 #define MAXSIZE 10 9 #define DLEN 4 // 对应于MAXN的大小 10... 阅读全文
posted @ 2016-09-02 00:46 Yan_Bin 阅读(356) 评论(0) 推荐(0) 编辑
摘要:1 #include 2 #include 3 #define ll long long 4 const int maxn = 505; 5 ll n,m,d,k,a[maxn]; 6 struct mat{ // 结构体循环矩阵,原矩阵式方阵 7 ll v[maxn]; 8 mat() {memset(v,0,sizeof(v));} // 构造函数 9 ... 阅读全文
posted @ 2016-09-01 00:48 Yan_Bin 阅读(320) 评论(0) 推荐(0) 编辑
摘要:1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 // 矩阵的STL实现 7 typedef vector vec; 8 typedef vector mat; 9 typedef long long ll; 10 const int MOD = 10000; 11 // 矩阵乘法 ... 阅读全文
posted @ 2016-08-31 23:29 Yan_Bin 阅读(221) 评论(0) 推荐(0) 编辑
摘要:1 #include 2 #include 3 const int maxn = 100; 4 typedef struct{ 5 long long Mat[maxn][maxn]; 6 }MAT; 7 long long MOD,d; // d是方阵的行数或者列数 8 // 方阵的乘法,模MOD 9 MAT mul(MAT a,MAT b){ 10 MAT c;... 阅读全文
posted @ 2016-08-31 23:24 Yan_Bin 阅读(181) 评论(0) 推荐(0) 编辑
摘要:1 #include 2 #include 3 #include 4 const int maxn = 100; 5 typedef double Matrix[maxn][maxn]; 6 // 要求系数矩阵可逆 7 // 这里A是增广矩阵,A[i][n]表示第i个方程右边的常数bi 8 // 运行结束后A[i][n]是第i个未知数的值 9 void gauss_eli... 阅读全文
posted @ 2016-08-31 00:23 Yan_Bin 阅读(116) 评论(0) 推荐(0) 编辑
摘要:1 #include 2 #include 3 #include 4 #include 5 typedef long long LL; 6 int mul_mod(int a,int b,int n){ // a、b都小于n 7 return a * b % n; 8 } 9 int pow_mod(int a,int p,int n){ 10 if(p... 阅读全文
posted @ 2016-08-26 00:27 Yan_Bin 阅读(965) 评论(0) 推荐(0) 编辑
摘要:1 #include 2 #include 3 #include 4 using namespace std; 5 typedef long long LL; 6 // 求x和y使得ax+by=d并且|x|+|y|最小。其中d=gcd(a,b) 7 void exgcd(LL a,LL b,LL& d,LL& x,LL& y){ 8 if(!b) d = a,x =... 阅读全文
posted @ 2016-08-25 17:39 Yan_Bin 阅读(148) 评论(0) 推荐(0) 编辑
摘要:1 #include 2 #include 3 #include 4 using namespace std; 5 typedef long long LL; 6 // 求x和y使得ax+by=d并且|x|+|y|最小。其中d=gcd(a,b) 7 void exgcd(LL a,LL b,LL& d,LL& x,LL& y){ 8 if(!b) d = a,x =... 阅读全文
posted @ 2016-08-25 17:18 Yan_Bin 阅读(637) 评论(0) 推荐(0) 编辑
摘要:也可以由欧拉定理,对任意a属于Zn,a^(phi(n))=1(modn)。于是a的逆就是a^(phi(n) - 1)。 如果n是素数的话,a的逆就是pow_mod(a,n-2,n) 阅读全文
posted @ 2016-08-25 00:53 Yan_Bin 阅读(153) 评论(0) 推荐(0) 编辑
摘要:1 #include 2 #include 3 #include 4 // 计算欧拉phi函数。phi(n)是不超过n且与n互素的正整数个数 5 int euler_phi(int n){ 6 int m = (int)sqrt(n + 0.5); 7 int ans = n; 8 // phi(n)=n(1-1/p1)(1-1/p2)...(1-1... 阅读全文
posted @ 2016-08-25 00:36 Yan_Bin 阅读(658) 评论(0) 推荐(0) 编辑
摘要:1 #include 2 #include 3 #include 4 using namespace std; 5 typedef long long LL; 6 LL pow_mod(LL a,LL p,LL n){ 7 if(p == 0) return 1; 8 LL ans = pow_mod(a,p / 2,n); 9 ans = ans... 阅读全文
posted @ 2016-08-24 23:56 Yan_Bin 阅读(107) 评论(0) 推荐(0) 编辑
摘要:1 #include 2 #include 3 #include 4 using namespace std; 5 typedef long long LL; 6 // 求x和y使得ax+by=d并且|x|+|y|最小。其中d=gcd(a,b) 7 void exgcd(LL a,LL b,LL& d,LL& x,LL& y){ 8 if(!b) d = a,x =... 阅读全文
posted @ 2016-08-24 23:50 Yan_Bin 阅读(107) 评论(0) 推荐(0) 编辑
摘要:1 #include 2 #include 3 #include 4 using namespace std; 5 const int maxn = 10000000; 6 const int maxp = 700000; 7 const int MOD = 1e9; 8 typedef long long LL; 9 int vis[maxn]; //vis[i] =... 阅读全文
posted @ 2016-08-24 23:43 Yan_Bin 阅读(148) 评论(0) 推荐(0) 编辑
摘要:map实例代码: 1 // UVa156 Ananagrams 2 // Rujia Liu 3 // 题意:输入一些单词,找出所有满足如下条件的单词:该单词不能通过字母重排得到输入文本中的另外一个单词 4 // 算法:把每个单词“标准化”,即全部转化为小写字母然后排序,然后放到map中进行统计 5 阅读全文
posted @ 2016-08-23 12:08 Yan_Bin 阅读(1082) 评论(0) 推荐(0) 编辑
摘要:以point结构体为例 阅读全文
posted @ 2016-08-23 11:01 Yan_Bin 阅读(106) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示