
模板
盘古工作室
这个作者很懒,什么都没留下…
展开
-
快速幂取余
下面是快速幂的介绍:先贴一个秦九韶算法(Horner算法)的原理:设有项的次函数将前项提取公因子,得再将括号内的前项提取公因子,得如此反复提取公因子,最后将函数化为令......则即为所求下面是讲解快速幂的:(By 夜せ︱深 感谢作者)快速幂取模算法在网站上一直没有找到有关于快速幂算法的一个详转载 2015-08-09 23:12:36 · 455 阅读 · 0 评论 -
最大m子段和模板
最大m子段和模板 int max(int *a,int m,int n)//a为初始数据 m为段数 n为数据长度,数据从下标1开始 { int *c; int *p; int max1, i, j; c=new int[n+1]; p=new int[n+1]; for(i=0; i原创 2016-05-25 17:21:22 · 347 阅读 · 0 评论 -
并查集
并查集void make(int x){ for (int i = 0; i <= x; i++) p[i] = i;}int find(int x){ if (x != p[x]) p[x] = find(p[x]); return p[x];}void unio(int x, int y){ int px = fin原创 2016-05-25 17:21:01 · 297 阅读 · 0 评论 -
ACM头文件
ACM头文件#include<iostream>#include<stdio.h>#include<cmath>#include<algorithm>#include<string>#include<cstring>#include<string.h>#include<map>#include<queue>#include<stack>#include<list>#inclu原创 2016-05-25 17:20:06 · 928 阅读 · 0 评论 -
最长公共递增子序列
最长公共递增子序列int LCIS(){ int ans = 0; for (int i = 1; i <= n; i++) { int k = 0; for (int j = 1; j <= m; j++) { if (a[i] == b[j]) {原创 2016-05-25 17:19:14 · 368 阅读 · 0 评论 -
快速幂函数
快速幂函数__int64 multimod(__int64 x, __int64 n, __int64 mod){ __int64 tmp = x, res = 1LL; while (n) { if (n & 1LL) { res *= tmp; res %= mod; }原创 2016-05-25 17:17:15 · 396 阅读 · 0 评论 -
矩阵快速幂
矩阵快速幂#include <cstdio>#include <iostream>using namespace std;const int MOD = 10000;struct matrix{ int m[2][2];}ans, base;matrix multi(matrix a, matrix b){ matrix tmp; for(int i = 0; i <原创 2016-05-25 17:16:54 · 110 阅读 · 0 评论 -
二分乘法
二分乘法 1 #define LL __int64 2 3 //计算 a*b % mod 4 LL Produc_Mod(LL a, LL b, LL mod) { 5 LL sum = 0; 6 while(b) { 7 if(b & 1) sum = (sum + a) % mod; 8 a =转载 2016-05-25 17:16:33 · 396 阅读 · 0 评论 -
母函数
母函数#include <iostream>using namespace std;// Author: Tanky Woo// www.wutianqi.comconst int _max = 10001; // c1是保存各项质量砝码可以组合的数目// c2是中间量,保存每一次的情况int c1[_max], c2[_max]; int main(){ //int n,原创 2016-05-25 17:16:06 · 106 阅读 · 0 评论 -
矩阵快速幂
矩阵快速幂#include<iostream>#include<cstdio>using namespace std;struct Matrix{ __int64 map[3][3];};Matrix operator*(Matrix a,Matrix b){ int i,j,k; Matrix tmp; for(i=0;i<3;++i)原创 2016-05-25 17:15:36 · 82 阅读 · 0 评论 -
二分图最大匹配
二分图最大匹配#include<iostream>#include<stdio.h>#include<cmath>#include<algorithm>#include<string>#include<cstring>#include<string.h>#include<map>#include<queue>#include<stack>#include<list>#incl原创 2016-05-25 17:22:57 · 317 阅读 · 0 评论