- 博客(11)
- 收藏
- 关注
原创 记录个人在洛谷试练场做题历程:二分答案:膨胀的木棍
http://noi.openjudge.cn/ch0111/09/#include<cstdio>#include<cmath>using namespace std;int main(){ double l,n,c,L; scanf("%lf%lf%lf",&l,&n,&c); L=l*(1+n*c); double le=0....
2018-04-01 18:04:26 547
原创 记录个人在洛谷试练场做题历程:模拟,玩具谜题
https://www.luogu.org/problemnew/show/P1563#include<cstdio>#include<cstring>#include<algorithm>using namespace std;struct node { char s[11]; int di;}a[100010];int main(){ int n,m,d,l...
2018-04-01 17:38:20 672
原创 解决乘法逆元的三种方法
1、拓展欧几里得#include<bits/stdc++.h>#define ll long longusing namespace std;ll n,p,x,y;void exgcd(ll a,ll b,ll &x,ll &y){ if(b==0){ x=1; y=0; return; } exgcd(b,a%b,x,y); ll t...
2018-02-14 18:46:55 974
原创 KMP:字符串匹配
#include<bits/stdc++.h>using namespace std;int next[1000005];char a[1000005],b[1000005];int main(){ scanf("%s%s",&a,&b); int lena=strlen(a),lenb=strlen(b); int i=0,j=-1; next[0]=-1; whil...
2018-02-14 17:07:28 169
原创 线段树:区间修改,区间求和
#include<cstdio>#define ll long longusing namespace std;const int M=400001;int n,m,k,x,y,val;ll a[M],sum[M],lazy[M];void pushup(int index){ sum[index]=sum[index<<1]+sum[index<<1|1...
2018-02-14 15:25:40 198
原创 hash:RK算法字符串匹配
#include<bits/stdc++.h>using namespace std;const int d=26,q=144451;int A,B,lena,lenb,h=1; char a[101],b[101];//a为主串,b为匹配串 int match(int index){ for(int i=index,j=0;i<lenb&&j<lenb;+...
2018-02-14 15:16:04 759
原创 树状数组(区间更新,区间查询)
#includeusing namespace std;const int M=500005;int a[M],c[M],c1[M],c2[M];int n,m,k,x,y,z;int lowbit(int t){ return t&(-t);}void update(int l,int r,int val){ for(int i=l;i
2018-02-03 18:41:48 160
原创 树状数组(区间更新,单点查询)
#includeusing namespace std;const int M=500005;int a[M],c[M],c1[M];int n,m;int lowbit(int t){return t&(-t);}void update(int l,int r,int val){//区间更新只相当于更新c[l]+=val,c[r+1]-=val;下面为
2018-02-03 17:39:33 377
翻译 树状数组(单点更新,区间查询)
#includeusing namespace std;int n,m,k,x,y,sum;int a[500005],c[500005];int lowbit(int t){return t&(-t);}void update(int x,int val){for(int i=x;i{c[i]+=val;}}void getsum(in
2018-02-03 11:11:51 297
原创 RMQ求LCA
#include#include#include#include#includeusing namespace std;const int M=500001;int n,m,s,a,b;int f[M*2],d[M*2],l[M*2],dfn;bool vis[2*M];int dp[2*M][20],pos[2*M][20];struct node
2017-12-28 18:07:25 188
原创 targan求LCA
#include#include#include#includeusing namespace std;const int M=1000000+10;struct edge{int next,to;}tree[M];struct node {int next,to,index;}que[M];bool vis[M];int n,m,s,a
2017-12-10 17:47:20 361 2
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人