随笔分类 -  [0-0]模板与讲解

摘要:1.已知二维平面内三点坐标求三角形面积 ll solve(ll x1,ll y1,ll x2,ll y2,ll x3,ll y3){ return abs(x1*y2+x3*y1+x2*y3-x1*y3-y1*x2-x3*y2);//注意面积为返回这的一半 } 2.海伦公式 a,b,c分别为三角形三 阅读全文
posted @ 2020-03-09 10:02 waryan 阅读(800) 评论(0) 推荐(1)
摘要:朴素素数筛 bool isprime(int n) { if(n==1) return 1; int t=sqrt(n); for(int i=2;i<=t;++i) if(n%i==0) return 1; return 0; } 埃氏筛: const int maxn=1e5+10; int p 阅读全文
posted @ 2020-03-09 09:07 waryan 阅读(127) 评论(0) 推荐(0)
摘要:POJ-3495 题解: #include <iostream> #include<algorithm> #include <cstdio> #include <cstdlib> #include <cstring> #include <queue> #define INF 0x3f3f3f3f # 阅读全文
posted @ 2020-01-30 23:06 waryan 阅读(532) 评论(0) 推荐(0)
摘要:1.单点修改裸题(HDU1754) #include<iostream> #include<algorithm> using namespace std; const int maxn=2e+5; int n,m,a[maxn]; struct tree{ int l,r,v; }trees[max 阅读全文
posted @ 2020-01-29 17:47 waryan 阅读(207) 评论(0) 推荐(1)
摘要:一:差分数组概念 一、差分数组的定义及用途 1.定义:对于已知有n个元素的数列d,建立记录它每项与前一项差值的差分数组f:显然,f[1]=d[1]-0=d[1];对于整数i∈[2,n],我们让f[i]=d[i]-d[i-1]。//f[i]数组为差分数组,d[i]数组为原数组 2.简单性质:(1)计算 阅读全文
posted @ 2020-01-28 21:45 waryan 阅读(861) 评论(0) 推荐(1)
摘要:一:模板题与解释 1.仅有定义即可完成优先队列(题面) #include<bits/stdc++.h> using namespace std; typedef long long ll; int main() { ios_base::sync_with_stdio(0); cin.tie(0); 阅读全文
posted @ 2020-01-28 16:02 waryan 阅读(131) 评论(0) 推荐(0)
摘要:一.st取区间最大值 模板题洛谷P3865:https://www.luogu.com.cn/problem/P3865 注意点: 1.f[i][j]=f[i][i+2j-1] 2.预处理时是以2的次幂进行跳的取区间最大值 3.query询问函数: 询问时取的len的方法是由:2x<=r-l+1来取 阅读全文
posted @ 2020-01-27 22:21 waryan 阅读(248) 评论(0) 推荐(0)
摘要:const int N=120; int father[N]; int rank1[N]; void init(int Size) { for(int i=1;i<=Size;++i) father[i]=i,rank1[i]=0; } int Find(int x) { while(x!=fath 阅读全文
posted @ 2020-01-23 18:20 waryan 阅读(158) 评论(0) 推荐(0)
摘要:1.油田连通块 链接地址:地址 递归DFS 1 #include<cstdio> 2 #include<iostream> 3 #include<algorithm> 4 #include<cstring> 5 using namespace std; 6 char map[110][110]; 7 阅读全文
posted @ 2020-01-12 11:50 waryan 阅读(124) 评论(0) 推荐(0)
摘要:一:求约数个数 约数个数定理: a.分解质因数(一个合数可以分通过质因数分解彻底) b.因数和(如何得来:将分解质因数的分开然后相乘共f(n)个) int get_num(int n) { int tot=1; for(int i=2;i*i<=n;++i) { if(n%i==0) { int x 阅读全文
posted @ 2020-01-12 11:50 waryan 阅读(174) 评论(0) 推荐(0)
摘要:问题: 如果正整数大于了1000有什么影响? 1.递推式gcd: 1 int gcd(int a,int b) 2 { 3 while(b>0) 4 { 5 int c=a%b; 6 a=b; 7 b=c; 8 } 9 return a; 10 } 2.递归式gcd: 1 int gcd(int a 阅读全文
posted @ 2020-01-12 11:50 waryan 阅读(87) 评论(0) 推荐(0)
摘要:1.普通快速幂 快速幂模板: 1 int Quick_pow(int a,int b) 2 { 3 int ans=1; 4 while(b){ 5 if(b&1) 6 ans=ans*a; 7 a=a*a; 8 b>>=1; 9 } 10 return ans; 11 } 矩阵快速幂模板 1 ma 阅读全文
posted @ 2020-01-12 11:50 waryan 阅读(136) 评论(0) 推荐(0)