自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(383)
  • 收藏
  • 关注

转载 poj1721

题解:直接暴力循环节然后再做几次代码:#include<cstdio>#include<cstring>#include<algorithm>#include<cmath>const int N=1005; int n,s,p[N],a[N],B[N]; void GetNext(int n) ...

2018-05-01 20:09:00 129

转载 poj1026

题解:似乎大家都是求置换群的取模啊给一个不同的思路快速幂!!!似乎速度比取模快多了(nlogk)代码:#include<cstdio>#include<cmath>#include<cstring>#include<algorithm>using namespace std;const int...

2018-05-01 19:22:00 138

转载 bzoj2369

题解:显然把每一个环求出来然后做一个lcm即可代码:#include<cstdio>using namespace std;int a[1005],f[1005],n;int gcd(int x,int y){ if (!y)return x; return gcd(y,x%y);}int main(){...

2018-05-01 18:42:00 169

转载 bzoj1668

题解:简单dp注意最后往后面多取几个求个最小值代码:#include<bits/stdc++.h>using namespace std;const int N=60005;int n,m,f[N],a[N],b[N];int main(){ scanf("%d%d",&n,&m); m+=500...

2018-04-27 18:50:00 126

转载 bzoj1688

题解:暴力枚举生哪一些病然后判断一下即可代码:#include<bits/stdc++.h>using namespace std;const int N=1005,D=17;int d,k,n,a[N][D],num;int main(){ scanf("%d%d%d",&n,&d,&k); ...

2018-04-27 18:37:00 114

转载 bzoj4700

题解:cdq分治先考虑没有人被秒掉的情况代码:#include<bits/stdc++.h>#define y1 ____y1const int N=300005; using namespace std; typedef long long ll; int bh[N],q[N],bhd[N],bha[N],A[N],d[N],P...

2018-04-27 18:23:00 128

转载 bzoj2748

题解:简单dp代码:#include<bits/stdc++.h> using namespace std;const int N=1005;int n,x,m,a[N],f[N][N];int main(){ scanf("%d%d%d",&n,&x,&m); for (int i=1;i&lt...

2018-04-26 20:56:00 112

转载 bzoj2705

题解:欧拉函数首先枚举gcd(n,i),然后计数也就是求phi(n/i)暴力枚举即可代码:#include<bits/stdc++.h>using namespace std;#define int long longconst int N=100005;int n,ans,flag[N],p[N];int phi(int x)...

2018-04-26 19:24:00 116

转载 spoj Ae2b

题解:设最后为x1+t1k+t2n,y1+t3k+t4n显然t1,t4或t2,t3同余(mod 2)然后exgcd一下代码:#include<bits/stdc++.h>#define y1 ___y1using namespace std;int test,a,b,x1,x2,y1,y2,x,y,g;int gcd(int a,int...

2018-04-18 17:40:00 110

转载 spoj mpoint

题解:判断每一次加进来的时候有几个被破坏,几个添加然后单调栈维护代码:#include<bits/stdc++.h>using namespace std;const int N=5005;int n,j,k,ans=0,now,oo=10000000;struct note{int x,y,id;}a[N],b[N];bool cmp...

2018-04-16 18:58:00 92

转载 spoj mgame

题解:f[i][j]表示先后手最大差g[i][j]表示在最大差的时候是否有后手没得走代码:#include<bits/stdc++.h>using namespace std;const int N=105;int n,m,q,x,y,a[N][N];double f[N][N];char s[105];int can(int x,...

2018-04-16 18:30:00 91

转载 spoj Minimax Triangulation

题解:dp+计算几何F[i][j]表示第i-j条边的答案然后转移一下代码:#include<bits/stdc++.h>using namespace std;struct note{int x,y;}a[55]; int T,n,f[55][55];int xot(note a,note b){return a.x*b.y-b.x*a...

2018-04-15 21:00:00 80

转载 spoj periodni

题解:dp方程弄出来就好做了代码:#include<bits/stdc++.h> const int N=505,M=1000000007;typedef int arr[N];typedef long long ll;int n,k,c[N][N],h[N];arr g;void add(int &x,int y){x+=...

2018-04-15 20:23:00 171

转载 spoj gcdex

题解:首先我们设gcd(i,j)=k所以我们就要求对于所有k的方案总数可以线性帅选欧拉函数然后算法一:枚举k,O(NT)算法二:考虑到我们只要n/k的整数部分容易证明是sqrt(n)级别的所以就可以在O(Tsqrt(n))的时间内解决但是要考虑卡常数代码:#include<bits/stdc++.h>typedef long l...

2018-04-15 20:22:00 122

转载 spoj Mfish

题解:先按照pos排序我们考虑每个船的结束为止endiendi-len[i]+1>=pos[i-1],end[i]>=pos[i],end[i]<pos[i+1]显然每一个位置的endi唯一所以就可以dp了代码:#include<bits/stdc++.h>using namespace std;const int N...

2018-04-15 20:20:00 98

转载 bzoj1452

题解:二位树状数组然后我开了300*300*300就T了代码:#include<bits/stdc++.h>using namespace std;const int N=305;int n,m,opt,z,a[N][N],dx,dy,x,y,f[N][N][105],q;int find(int x,int y,int z){ ...

2018-04-13 19:55:00 81

转载 bzoj1044

题解:第一问二分答案第二问dp+单调队列代码:#include<bits/stdc++.h>const int M=10007,N=50005;typedef long long ll;using namespace std;int n,m,ans1,ans2,a[N],sum[N],f[2][N],q[N];int jud(int x...

2018-04-12 18:31:00 110

转载 bzoj2186

题解:把逆元求出来然后预处理代码:#include<bits/stdc++.h>const int N=10000005;typedef long long ll;using namespace std;int T,R,n,m,cnt,fac[N],ine[N],pri[N],ans[N],mark[N];void pre(){...

2018-04-09 18:07:00 62

转载 bzoj1202

题解:差分约束系统建立反相变然后看看有木有无穷大即可代码:#include<bits/stdc++.h>using namespace std;const int N=2005;int T,n,m,fi[N],tot,x,y,z,f[N],dis[N],num[N],ne[N],sl[N],zz[N];queue<int >...

2018-04-08 18:51:00 92

转载 bzoj2190

题解:显然当坐标不互质的时候是可以看得见的所以线性筛选欧拉函数代码:#include<bits/stdc++.h>using namespace std;const int N=80005;int n,ans,p[N],phi[N],prime[N];void getphi(){ phi[1]=1; for (i...

2018-04-08 17:43:00 65

转载 bzoj5016

题解:吧询问变成前缀形式然后莫队代码:#include<bits/stdc++.h>const int N=50005;using namespace std;struct ques{int l,r,id,ad;}q[N*4];int n,block[N],size,a[N],num1[N],num2[N],m,tot=0,L=0,R=0;...

2018-04-05 13:48:00 114

转载 bzoj2330

题解:差分约束系统要我们求最小值显然就是转化为最长路然后spfa一下即可代码:#include<bits/stdc++.h>using namespace std;const int N=400005;long long ans,dis[N];int n,m,op,x,y,sl[N],Q[N],flag[N],tot,zz[N],f...

2018-04-03 19:12:00 126

转载 bzoj1096

题解:斜率优化dp代码:#include<bits/stdc++.h> typedef long long ll;const int N=1000005;using namespace std;int n,l,r,q[N];ll p[N],x[N],c[N],f[N],b[N],sum[N];double slop(int k,int ...

2018-04-03 17:53:00 95

转载 bzoj1221

题解:费用流构图才是难点代码:#include<bits/stdc++.h>const int N=2005,T=2001;using namespace std;int x,cnt=1,day,p,m,f,n,s,ans,from[N],q[N],dis[N],head[N],inq[N];struct data{int from,to,...

2018-03-31 21:33:00 90

转载 hdu3377

题解:简单的插头dp加上一个代价即可代码:#include<cstdio>#include<cmath>#include<cstring>#include<algorithm>using namespace std;const int N=15,HASH=10007,STATE=1000100,M=1...

2018-03-29 17:58:00 136

转载 bzoj3930

题解:莫比乌斯函数然而向我这种弱菜肯定选择暴力dp代码:#include<bits/stdc++.h>const int N=100010,M=1000000007;typedef long long ll; using namespace std; int n; ll m,L,R,k,f[N]; ll power(ll ...

2018-03-28 17:29:00 65

转载 bzoj3976

题解:先跑一下Sa然后再用kmp匹配一下哪一些位置不行然后二分答案代码:#include<bits/stdc++.h>const int N=100003;using namespace std;int t[N],a[N],xx[N],yy[N],*x,*y,height[N],rank[N],sa[N];int n,m,len,len...

2018-03-26 19:22:00 62

转载 bzoj4237

题解:cdq分治二位变成一维二分一下代码:#include<bits/stdc++.h>using namespace std;typedef long long LL;const int N=200011;int n,Stack[N],top,Stack2[N],tail;LL ans;struct node{int x,y;...

2018-03-26 18:48:00 82

转载 fzu1977

题解:和前两题差不多只不过变成了有些一定走,有些不一定代码:#include<cstdio>#include<cmath>#include<algorithm>#include<cstring>using namespace std; typedef long long ll;const int...

2018-03-26 18:25:00 75

转载 hdu1693

题解:还是插头dp代码:#include<cstdio> #include<cstring> #include<algorithm> #include<cmath> using namespace std; int gp[12][12],n,m; long long dp[13][13...

2018-03-25 21:00:00 105

转载 ural1519

题解:插头dp具体可以看看cdq论文代码:#include<bits/stdc++.h>using namespace std;typedef long long ll;const int N=128483;int n,m,ex,ey;char s[15][15];struct node{ int H[N],tot,s...

2018-03-25 20:21:00 113

转载 bzoj1264

题解:60分的dp还是很好想的首先观察dp只有在相同的时候才会转移所以我们可以维护5个相同的点然后再加上树状数组代码:#include<bits/stdc++.h>const int N=200005;using namespace std; int n,ans,a[N],b[N],c[N],f[N],pos[N][6]; ...

2018-03-22 19:31:00 65

转载 bzoj1009

题解:kmp然后列出来矩阵加上快速幂即可代码:#include<bits/stdc++.h>using namespace std;const int N=30;int n,m,M,p[N],a[N][N],b[N][N];char ch[N];void mul(int a[N][N],int b[N][N],int ans[N][...

2018-03-22 17:47:00 67

转载 bzoj2045

题解:莫比乌斯反演经典题目直接套公式好了代码:#include<bits/stdc++.h>using namespace std;const int N=1000005;typedef long long ll;int n,m,k,p[N],tot,flag[N],miu[N];ll ans,ans2;void init(){...

2018-03-18 18:46:00 86

转载 bzoj1303

题解:首先把>b的标记为1小于b的标记为-1然后更具乘法原理做代码:#include<bits/stdc++.h>using namespace std;const int N=200005;int num[N],sum[N],l[N],r[N],n,b,point,ans;int main(){ scanf("%d...

2018-03-18 18:29:00 66

转载 bzoj1651

题解:前缀和维护f[a]++,f[b+1]--然后F[i]+=f[i-1]代码:#include<bits/stdc++.h>using namespace std;const int N=1000005;int a,b,n,f[N],ans;int main(){ scanf("%d",&n); whi...

2018-03-18 16:06:00 92

转载 bzoj3412

题解:先把询问排序然后根据单调性来做代码:#include<bits/stdc++.h>using namespace std;int n,m,a[50005],b[50005],f[50005],ans[50005];int cmp(int x,int y){ return b[x]<b[y];}int main(...

2018-03-17 13:47:00 166

转载 spoj1811

题解:后缀自动机先把A的后缀自动机建好然后用B再上面跑如果不能转移就跳fail如果可以就到下一个可行状态代码:#include<bits/stdc++.h>using namespace std;const int N=250005;char b[N],a[N];int n,m,cnt,la;struct State{...

2018-03-16 20:15:00 72

转载 bzoj1935

题解:x升序排序y离散化+树状数组代码:#include<bits/stdc++.h>using namespace std;const int N=500005;inline int read(){ int x=0,f=1;char ch=getchar(); while(ch<'0'||ch>'9'){i...

2018-03-15 21:09:00 64

转载 bzoj3997

题解:dpf[i][j]=max(f[i-1][j+1]+a[i][j],max(f[i-1][j],f[i][j+1]));代码:#include<bits/stdc++.h>using namespace std;const int N=1005;int T,n,m,a[N][N],f[N][N];int main(){ ...

2018-03-14 21:10:00 141

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除