
模板
JW_7066
这个作者很懒,什么都没留下…
展开
-
hdu 5901(模板,10^11以内的素数个数)
Count primes Time Limit: 12000/6000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)原创 2016-09-23 19:11:39 · 2158 阅读 · 0 评论 -
欧拉函数
在数论,对正整数n,欧拉函数是小于等于n的数中与n互质的数的数目。ll phi(ll x) { ll ans = x; for(ll 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); r原创 2016-11-25 15:41:46 · 564 阅读 · 0 评论 -
manacher算法模板
内存较大的:#include #include #include #include #include using namespace std; #define inf 310010 char s[inf], str[inf]; int p[inf], len; void gets() { int li = strlen(str);原创 2016-11-23 23:42:50 · 599 阅读 · 0 评论 -
树状数组小结
树状数组看了很久终于懂了!!以下就是我的理解(参考白书P194以及点击打开链接)树状数组也就是二叉索引树(Binary Indexed Tree,BIT)它的作用就只有两个:1、单点更新 2、区间求和一、lowbit的理解定义:lowbit(x)是x的二进制表达式中最右边的1所对应的值。比如,6的二进制是110,所以lowbit(6)=2在代码中lo原创 2015-07-15 21:21:06 · 953 阅读 · 0 评论 -
网络流
一、最大流之增广路算法这个博客讲解放入挺详细的:点击打开链接前向弧:离开点u的有向弧后向弧:进入点u的有向弧【恩~有一点我觉得有必要记录一下】建立这些后向弧的必要性:如果不建立后向边就容易出现上面这种情况,结果会偏小,路径是:1->2->5、1->2->3->5、1->3->5。建立后向边之后,路径会增加一条:1->2->5、1->2->3->5、1->3-原创 2016-10-06 22:10:58 · 640 阅读 · 0 评论 -
RMQ 区间最值的问题
int RMQ(int L, int R) { int k = 0; while((1<<(k+1)) <= R-L+1) k++; //如果2^k+1 <= R-L+1,那么k还可以加1 return min(d[L][k], d[R-(1<<k)+1][k]); }原创 2016-10-22 23:14:32 · 497 阅读 · 0 评论 -
LIS && LCS && LCIS
1、LIS:一个a序列,求它的最大上升子序列的最大长度2、LCS:两个序列a和b,求他们最大公共子序列的长度 3、LCIS:两个序列a、b,求他们最大公共上升子序列长度【求长度并输出序列:CF10D. LCIS】#include using namespace std;int a[1010], b[1010];int f[1010], fa[1010];原创 2016-10-27 23:13:28 · 464 阅读 · 0 评论 -
hash
#include using namespace std;#define ll __int64#define ull unsigned long long //自动取余 const int inf = 5e6+10; const ull bas = 311; ull lhas[inf], rhas[inf], base[inf]; char s[inf]; int m原创 2016-10-24 09:59:35 · 433 阅读 · 0 评论 -
扩展欧几里得
扩展欧几里得定理:对于两个不全为0的整数a、b,必存在一组解x,y,使得ax+by==gcd(a,b)#include using namespace std;#define ll __int64ll gcd(ll a, ll b) { ll res = a; while(b) { res = a%b; a = b, b = res; } return a;}原创 2016-10-23 20:58:22 · 422 阅读 · 0 评论 -
并查集
【一次做cf,用递归版的超时了,非递归版的就ac了】递归版#include using namespace std;const int N=1e3;int fa[N];int find(int x){ return fa[x]==x?x:find(fa[x]); } void Union(int x, int y){ int fx = fin原创 2016-10-16 21:51:51 · 464 阅读 · 0 评论