summary:44
没救了。。。整天刷水迟早药丸!
❤bzoj3892:
区间dp。我原来的思路是dp[i][j]表示前i个数跳过了j次,那么转移可以前k个数转移了j-1次,枚举k就好了,但是这样是错的,因为前k个数转移了j-1次,那么再k到i之间到底要在哪一步跳无法确定。于是便WA了。正确的转移应该是前i-k-1个数转移了j-k次,在i-k-1到i直接跳过去就好了。dp的转移方程要多验证是否是对的。。。!
#include<cstdio> #include<cstring> #include<iostream> #include<algorithm> using namespace std; #define rep(i,s,t) for(int i=s;i<=t;i++) #define dwn(i,s,t) for(int i=s;i>=t;i--) #define clr(x,c) memset(x,c,sizeof(x)) int read(){ int x=0,f=1;char c=getchar(); while(!isdigit(c)){ if(c=='-') f=-1;c=getchar(); } while(isdigit(c)) x=x*10+c-'0',c=getchar(); return x*f; } const int nmax=505; const int inf=0x7f7f7f7f; int dp[nmax][nmax],x[nmax],y[nmax]; int as(int x){ return x<0?-x:x; } int main(){ int N=read(),K=read(); rep(i,1,N) x[i]=read(),y[i]=read(); clr(dp,0x7f);dp[1][0]=0; rep(i,2,N) { for(int j=0;j<=i-2&&j<=K;j++){ rep(k,0,j) dp[i][j]=min(dp[i][j],dp[i-k-1][j-k]+as(x[i]-x[i-k-1])+as(y[i]-y[i-k-1])); } } printf("%d ",dp[N][min(K,N-2)]); }
bzoj3891:
直接三次bfs就好了。我傻叉写了三个bfs。。。
#include<cstdio> #include<cstring> #include<iostream> #include<algorithm> #include<queue> using namespace std; #define rep(i,s,t) for(int i=s;i<=t;i++) #define clr(x,c) memset(x,c,sizeof(x)) #define qwq(x) for(edge *o=head[x];o;o=o->next) int read(){ int x=0;char c=getchar(); while(!isdigit(c)) c=getchar(); while(isdigit(c)) x=x*10+c-'0',c=getchar(); return x; } const int nmax=40005; const int maxn=100005; const int inf=0x7f7f7f7f; struct edge{ int to;edge *next; }; edge edges[maxn],*pt=edges,*head[nmax]; void add(int u,int v){ pt->to=v;pt->next=head[u];head[u]=pt++; pt->to=u;pt->next=head[v];head[v]=pt++; } int dist[nmax],dis[nmax],d[nmax],B,E,P,N,M; bool vis[nmax]; queue<int>q; void d1(){ clr(vis,0);vis[1]=1; d[1]=0;q.push(1); while(!q.empty()){ int x=q.front();q.pop(); qwq(x) if(!vis[o->to]){ d[o->to]=d[x]+1; q.push(o->to); vis[o->to]=1; } } } void d2(){ clr(vis,0);vis[2]=1; dis[2]=0;q.push(2); while(!q.empty()){ int x=q.front();q.pop(); qwq(x) if(!vis[o->to]){ dis[o->to]=dis[x]+1; q.push(o->to); vis[o->to]=1; } } } void d3(){ clr(vis,0);vis[N]=1; dist[N]=0;q.push(N); while(!q.empty()){ int x=q.front();q.pop(); qwq(x) if(!vis[o->to]){ dist[o->to]=dist[x]+1; q.push(o->to); vis[o->to]=1; } } } int main(){ B=read(),E=read(),P=read(),N=read(),M=read(); int u,v,tmp,temp; rep(i,1,M) u=read(),v=read(),add(u,v); d1();d2();d3(); int ans=inf; rep(i,1,N) ans=min(ans,B*d[i]+E*dis[i]+P*dist[i]); printf("%d ",ans); return 0; }
bzoj3943:
最大生成树。prim O(n2) kruskal O(eloge) 这道题边数很多用prim快了很多。
#include<cstdio> #include<cstring> #include<iostream> #include<algorithm> using namespace std; #define rep(i,s,t) for(int i=s;i<=t;i++) #define dwn(i,s,t) for(int i=s;i>=t;i--) #define clr(x,c) memset(x,c,sizeof(x)) #define ll long long int read(){ int x=0;char c=getchar(); while(!isdigit(c)) c=getchar(); while(isdigit(c)) x=x*10+c-'0',c=getchar(); return x; } const int nmax=2005; const int maxn=4000005; const int inf=0x7f7f7f7f; int a[nmax],n,f[nmax];ll ans; bool vis[nmax]; int main(){ n=read(); rep(i,1,n) a[i]=read(); int tmp; rep(i,1,n){ tmp=0; rep(j,1,n) if(!vis[j]&&f[j]>=f[tmp]) tmp=j; vis[tmp]=true;ans+=f[tmp]; rep(j,1,n) f[j]=max(f[j],a[tmp]^a[j]); } printf("%lld ",ans); return 0; } /*struct node{ int from,to,dist; bool operator<(const node&rhs)const{ return dist>rhs.dist;} }; node nodes[maxn]; int a[nmax],fa[nmax]; int find(int x){ return fa[x]==x?x:fa[x]=find(fa[x]); } int main(){ int n=read(),cnt=0; rep(i,1,n) { a[i]=read(); rep(j,1,i-1){ nodes[++cnt].from=j,nodes[cnt].to=i,nodes[cnt].dist=a[i]^a[j]; } } sort(nodes+1,nodes+cnt+1); rep(i,1,n) fa[i]=i; int ta,tb,sum=0;ll ans=0; rep(i,1,cnt){ ta=find(nodes[i].from);tb=find(nodes[i].to); if(ta!=tb){ fa[ta]=tb; sum++;ans+=nodes[i].dist; if(sum==n-1) break; } } printf("%lld ",ans); return 0; }*/
bzoj3942:
AC自动机强上。。判断是否是子串就可以了。
#include<cstdio> #include<cstring> #include<iostream> #include<algorithm> #include<queue> using namespace std; #define rep(i,s,t) for(int i=s;i<=t;i++) #define clr(x,c) memset(x,c,sizeof(x)) const int nmax=1000005; int ch[nmax][26],fail[nmax],F[nmax],T[nmax]; char s[nmax],t[nmax],S[nmax]; void insert(){ int len=strlen(s),t=0,pt=0; rep(i,0,len-1){ if(!ch[t][s[i]-'a']) ch[t][s[i]-'a']=++pt; t=ch[t][s[i]-'a']; } F[t]=len; } queue<int>q; void getfail(){ fail[0]=0;q.push(0); while(!q.empty()){ int x=q.front();q.pop(); rep(i,0,25) { if(ch[x][i]) q.push(ch[x][i]),fail[ch[x][i]]=x==0?0:ch[fail[x]][i]; else ch[x][i]=x==0?0:ch[fail[x]][i]; } } } int main(){ scanf("%s",t+1); scanf("%s",s);insert();getfail(); int len=strlen(t+1),top=0,x=0; rep(i,1,len){ S[++top]=t[i]; x=ch[x][t[i]-'a'];T[top]=x; if(F[x]) top-=F[x],x=T[top]; } rep(i,1,top) printf("%c",S[i]);printf(" "); return 0; }
bzoj3412:
lower_bound查找即可。。。
#include<cstdio> #include<cstring> #include<iostream> #include<algorithm> using namespace std; #define rep(i,s,t) for(int i=s;i<=t;i++) #define dwn(i,s,t) for(int i=s;i>=t;i--) #define clr(x,c) memset(x,c,sizeof(x)) int read(){ int x=0;char c=getchar(); while(!isdigit(c)) c=getchar(); while(isdigit(c)) x=x*10+c-'0',c=getchar(); return x; } const int nmax=50005; int sum[nmax]; int main(){ int n=read(),Q=read(),u,tmp,temp; sum[0]=-1; rep(i,1,n) u=read(),sum[i]=sum[i-1]+u; rep(i,1,Q){ u=read(); tmp=lower_bound(sum+1,sum+n+1,u)-sum; printf("%d ",tmp); } return 0; }
bzoj3431:
在枚举距离的同时枚举时间。不错的模拟!
#include<cstdio> #include<cstring> #include<iostream> #include<algorithm> using namespace std; #define rep(i,s,t) for(int i=s;i<=t;i++) #define clr(x,c) memset(x,c,sizeof(x)) const int nmax=10005; double a[nmax],b[nmax]; char s[5]; int main(){ int n,asum=0,bsum=0;scanf("%d",&n); double u,tmp,temp; rep(i,1,n){ scanf("%s%lf",s,&u); if(s[0]=='T') a[++asum]=u; else b[++bsum]=u; } b[++bsum]=1000; sort(a+1,a+asum+1); sort(b+1,b+bsum+1); int v=1,now=1; double pre=0,dist; rep(i,1,bsum){ dist=b[i]-b[i-1]; while(pre+dist*v>a[now]&&now<=asum){ dist-=(a[now]-pre)/v; pre=a[now];now++;v++; } pre+=dist*v; v++; //printf("%lf %d ",pre,v); } int ans=pre+0.5; printf("%d ",ans); return 0; }
bzoj3432:
二分答案即可。。。
#include<cstdio> #include<cstring> #include<iostream> #include<algorithm> #include<queue> using namespace std; #define rep(i,s,t) for(int i=s;i<=t;i++) #define dwn(i,s,t) for(int i=s;i>=t;i--) #define clr(x,c) memset(x,c,sizeof(x)) int read(){ int x=0;char c=getchar();int f=1; while(!isdigit(c)) { if(c=='-') f=-1;c=getchar(); } while(isdigit(c)) x=x*10+c-'0',c=getchar(); return x*f; } const int nmax=505; const int inf=0x7f7f7f7f; int map[nmax][nmax],t[nmax][nmax]; bool vis[nmax][nmax]; int N,M,cnt=0,ta,tb; struct node{ int x,y; node(int x,int y):x(x),y(y){}; }; queue<node>q; int as(int x){ return x<0?-x:x; } int xx[5]={0,0,0,1,-1}; int yy[5]={0,1,-1,0,0}; bool check(int mid){ int x,y,tx,ty,res=0; clr(vis,0);vis[ta][tb]=1; q.push(node(ta,tb)); while(!q.empty()){ node o=q.front();q.pop(); x=o.x,y=o.y; if(t[x][y]==1) res++; rep(i,1,4){ tx=x+xx[i],ty=y+yy[i]; if(tx<1||ty<1||tx>N||ty>M||as(map[tx][ty]-map[x][y])>mid||vis[tx][ty]) continue; q.push(node(tx,ty));vis[tx][ty]=1; } } return res==cnt; } int main(){ N=read(),M=read(); rep(i,1,N) rep(j,1,M) map[i][j]=read(); rep(i,1,N) rep(j,1,M) { t[i][j]=read(); if(t[i][j]==1) cnt++,ta=i,tb=j; } int l=0,r=inf,mid,ans=0; while(l<=r){ mid=(l+r)>>1; if(check(mid)) ans=mid,r=mid-1; else l=mid+1; } printf("%d ",ans); return 0; }
bzoj3410:
求最多能用多少个不相交的区间覆盖线段。贪心:按结束点排序,放不了就不要。
#include<cstdio> #include<cstring> #include<iostream> #include<algorithm> using namespace std; #define rep(i,s,t) for(int i=s;i<=t;i++) #define clr(x,c) memset(x,c,sizeof(x)) const int nmax=50005; int read(){ int x=0;char c=getchar(); while(!isdigit(c)) c=getchar(); while(isdigit(c)) x=x*10+c-'0',c=getchar(); return x; } struct node{ int l,r; bool operator<(const node&rhs)const{ return r<rhs.r;} }; node nodes[nmax]; int main(){ int N=read(),u,v; rep(i,1,N) nodes[i].l=read(),nodes[i].r=read(); sort(nodes+1,nodes+N+1); int ans=0,now=-1; rep(i,1,N) { if(nodes[i].l>=now) ans++,now=nodes[i].r; } printf("%d ",ans); return 0; }
❤bzoj3404:
对于游戏问题不怎么懂。。。可以先预处理出每个数是必胜/必败,该状态是必胜的当后续状态有状态是必败的,否则就是必败的。因为在预处理的时候第一次出现必败的情况他的后续状态都是必胜的,所以每个数都只有必胜或必败两种情况。
#include<cstdio> #include<cstring> #include<iostream> #include<algorithm> using namespace std; #define rep(i,s,t) for(int i=s;i<=t;i++) #define clr(x,c) memset(x,c,sizeof(x)) const int nmax=1000005; int ans[nmax]; int main(){ clr(ans,0); rep(i,1,9) ans[i]=1; int maxn,minn,tmp,temp; rep(i,10,nmax){ maxn=-1,minn=10; tmp=i; while(tmp){ temp=tmp%10; if(temp){ maxn=max(maxn,temp); minn=min(minn,temp); } tmp/=10; } if(maxn!=-1) ans[i]|=(!ans[i-maxn]); if(minn!=10) ans[i]|=(!ans[i-minn]); } int G;scanf("%d",&G); rep(i,1,G){ scanf("%d",&tmp); if(ans[tmp]) printf("YES "); else printf("NO "); } return 0; }
bzoj3433:
贪心。按结束点排序,优先进入较长的那个队。好神的贪心!
#include<cstdio> #include<cstring> #include<iostream> #include<algorithm> using namespace std; #define rep(i,s,t) for(int i=s;i<=t;i++) #define clr(x,c) memset(x,c,sizeof(x)) const int nmax=155; struct node{ int l,r; bool operator<(const node&rhs)const{ return r<rhs.r;} }; node e[nmax]; int main(){ int n;scanf("%d",&n); rep(i,1,n){ scanf("%d%d",&e[i].l,&e[i].r); e[i].r--; } sort(e+1,e+n+1); int now=-1,pre=-1,ans=0; rep(i,1,n){ if(e[i].l>now) ans++,now=e[i].r; else if(e[i].l>pre) ans++,pre=e[i].r; if(pre>now) swap(now,pre); } printf("%d ",ans); return 0; }
bzoj3403:
模拟。。。
#include<cstdio> #include<cstring> #include<iostream> #include<algorithm> using namespace std; #define rep(i,s,t) for(int i=s;i<=t;i++) const int nmax=200005; int a[nmax]; char s[5],ch[5]; int main(){ int N,l=100001,r=100000,cnt=0,tmp; scanf("%d",&N); rep(i,1,N){ scanf("%s%s",s,ch); if(s[0]=='A'){ cnt++; if(ch[0]=='L') a[--l]=cnt; else a[++r]=cnt; }else{ scanf("%d",&tmp); if(ch[0]=='L') l+=tmp; else r-=tmp; } } rep(i,l,r) printf("%d ",a[i]); return 0; }
bzoj3402:
边权为1,我傻叉还打了个dijkstra。。应该bfs一遍就好了吧。。。
#include<cstdio> #include<cstring> #include<iostream> #include<algorithm> #include<queue> using namespace std; #define rep(i,s,t) for(int i=s;i<=t;i++) #define clr(x,c) memset(x,c,sizeof(x)) #define dwn(i,s,t) for(int i=s;i>=t;i--) #define qwq(x) for(edge *o=head[x];o;o=o->next) int read(){ int x=0;char c=getchar(); while(!isdigit(c)) c=getchar(); while(isdigit(c)) x=x*10+c-'0',c=getchar(); return x; } const int nmax=20005; const int maxn=100005; const int inf=0x7f7f7f7f; struct edge{ int to;edge *next; }; edge edges[maxn],*pt=edges,*head[nmax]; void add(int u,int v){ pt->to=v;pt->next=head[u];head[u]=pt++; pt->to=u;pt->next=head[v];head[v]=pt++; } struct node{ int x,dist; node(int x,int dist):x(x),dist(dist){}; bool operator<(const node&rhs)const{ return dist>rhs.dist; } }; priority_queue<node>q; int dist[nmax]; void dijkstra(int s){ q.push(node(s,0)); clr(dist,0x7f);dist[s]=0; int x,d; while(!q.empty()){ node o=q.top();q.pop(); x=o.x;d=o.dist; if(d!=dist[x]) continue; qwq(x) if(dist[o->to]>d+1){ dist[o->to]=d+1; q.push(node(o->to,dist[o->to])); } } } int main(){ int N=read(),M=read(),u,v; rep(i,1,M){ u=read(),v=read(); add(u,v); } dijkstra(1); int ans=0; rep(i,1,N) ans=max(ans,dist[i]); int res,cnt=0; dwn(i,N,1) if(dist[i]==ans) res=i,cnt++; printf("%d %d %d ",res,ans,cnt); return 0; }
bzoj3401:
又是单调栈。。。usaco相似题怎么那么多
#include<cstdio> #include<cstring> #include<iostream> #include<algorithm> using namespace std; #define rep(i,s,t) for(int i=s;i<=t;i++) #define dwn(i,s,t) for(int i=s;i>=t;i--) #define clr(x,c) memset(x,c,sizeof(x)) int read(){ int x=0;char c=getchar(); while(!isdigit(c)) c=getchar(); while(isdigit(c)) x=x*10+c-'0',c=getchar(); return x; } const int nmax=1e5+5; int a[nmax],s[nmax],ans[nmax]; int main(){ int N=read(),r=0; rep(i,1,N){ a[i]=read(); while(r&&a[s[r]]<a[i]) ans[s[r]]=i,r--; s[++r]=i; } rep(i,1,N) printf("%d ",ans[i]); return 0; }
bzoj3400:
dp。可以压掉一维。
#include<cstdio> #include<cstring> #include<iostream> #include<algorithm> using namespace std; #define rep(i,s,t) for(int i=s;i<=t;i++) #define dwn(i,s,t) for(int i=s;i>=t;i--) #define clr(x,c) memset(x,c,sizeof(x)) int read(){ int x=0;char c=getchar(); while(!isdigit(c)) c=getchar(); while(isdigit(c)) x=x*10+c-'0',c=getchar(); return x; } const int nmax=1005; const int maxn=2005; const int mod=100000000; int dp[maxn][nmax]; int main(){ int N=read(),F=read(),u; u=read();dp[1][u%F]=1;dp[1][0]+=1; rep(i,2,N){ u=read(); rep(j,0,F-1) { dp[i][j]=(dp[i-1][j]+dp[i][j])%mod; dp[i][(j+u)%F]=(dp[i-1][j]+dp[i][(j+u)%F])%mod; } } printf("%d ",dp[N][0]-1); return 0; }//其实可以压掉一维。。如下。
#include<cstdio> #include<cstring> #include<iostream> #include<algorithm> using namespace std; #define rep(i,s,t) for(int i=s;i<=t;i++) #define dwn(i,s,t) for(int i=s;i>=t;i--) #define clr(x,c) memset(x,c,sizeof(x)) int read(){ int x=0;char c=getchar(); while(!isdigit(c)) c=getchar(); while(isdigit(c)) x=x*10+c-'0',c=getchar(); return x; } const int nmax=1005; const int mod=100000000; int dp[nmax]; int pre[nmax]; int main(){ int N=read(),F=read(),u,v; u=read();pre[u%F]=1;pre[0]++; rep(i,2,N){ u=read(); rep(j,0,F-1) { dp[j]=(dp[j]+pre[j])%mod; v=(j+u)%F; dp[v]=(pre[j]+dp[v])%mod; } rep(j,0,F-1) pre[j]=dp[j],dp[j]=0; } printf("%d ",pre[0]-1); return 0; }
bzoj3392:
bfs。。。
#include<cstdio> #include<cstring> #include<iostream> #include<algorithm> using namespace std; #define rep(i,s,t) for(int i=s;i<=t;i++) #define dwn(i,s,t) for(int i=s;i>=t;i--) #define clr(x,c) memset(x,c,sizeof(x)) #define qwq(x) for(edge *o=head[x];o;o=o->next) int read(){ int x=0;char c=getchar(); while(!isdigit(c)) c=getchar(); while(isdigit(c)) x=x*10+c-'0',c=getchar(); return x; } const int nmax=1005; const int maxn=50005; const int inf=0x7f7f7f7f; struct edge{ int to;edge *next; }; edge edges[maxn],*pt=edges,*head[nmax]; void add(int u,int v){ pt->to=v;pt->next=head[u];head[u]=pt++; } int q[nmax],dist[nmax]; int main(){ int N=read(),T=read(),u,v; rep(i,1,N) { u=read(),v=read(); add(u,v); } int l=1,r=1;q[1]=1; while(l<=r){ u=q[l];l++; qwq(u) if(!dist[o->to]){ dist[o->to]=dist[u]+1; q[++r]=o->to; if(o->to==T) { printf("%d ",dist[o->to]+1); return 0; } } } printf("-1 "); return 0; }
bzoj3016:
括号序列!以前看过然后不会。。。贪心!!!
#include<cstdio> int main(){ char c; int ans=0,cnt=0; while(1){ c=getchar(); if(c==' ') break; if(c=='(') cnt++; else if(c==')'){ cnt--; if(cnt<0) cnt+=2,ans++; } } printf("%d ",ans+(cnt>>1)); return 0; }
bzoj2019:
直接将点的权值装换到边上,然后判断是否有正环(-),spfa就好了。。
#include<cstdio> #include<cstring> #include<iostream> #include<algorithm> #include<queue> #include<deque> using namespace std; #define rep(i,s,t) for(int i=s;i<=t;i++) #define dwn(i,s,t) for(int i=s;i>=t;i--) #define clr(x,c) memset(x,c,sizeof(x)) #define qwq(x) for(edge *o=head[x];o;o=o->next) int read(){ int x=0;char c=getchar(); while(!isdigit(c)) c=getchar(); while(isdigit(c)) x=x*10+c-'0',c=getchar(); return x; } const int nmax=225; const int maxn=1005; const int inf=0x7f7f7f7f; struct edge{ int to,dist;edge *next; }; edge edges[maxn],*pt=edges,*head[nmax]; void add(int u,int v,int d){ pt->to=v;pt->dist=d;pt->next=head[u];head[u]=pt++; } queue<int>q; int dist[nmax],in[nmax]; bool inq[nmax]; bool spfa(int s,int D,int N){ clr(dist,0);dist[s]=-D; clr(inq,0);in[s]=1; q.push(s); while(!q.empty()){ int x=q.front();q.pop();inq[x]=0; qwq(x) if(dist[o->to]>dist[x]+o->dist){ dist[o->to]=dist[x]+o->dist; if(!inq[o->to]){ in[o->to]++; if(in[o->to]>N) return 0; q.push(o->to);inq[o->to]=1; } } } return 1; } int main(){ int D=read(),M=read(),N=read(),P=read(),S=read(),u,v,d; rep(i,1,M) { u=read();v=read(),add(u,v,-D); } rep(i,1,P) { u=read();v=read();d=read(); add(u,v,d-D); } if(spfa(S,D,N)) { int ans=0; rep(i,1,N) ans=max(ans,-dist[i]); printf("%d ",ans); }else printf("-1 "); return 0; }
❤bzoj2101:
神dp。。。然后可以枚举间距巧妙压掉一维。
#include<cstdio> #include<cstring> #include<iostream> #include<algorithm> using namespace std; #define rep(i,s,t) for(int i=s;i<=t;i++) #define clr(x,c) memset(x,c,sizeof(x)) int read(){ int x=0;char c=getchar(); while(!isdigit(c)) c=getchar(); while(isdigit(c)) x=x*10+c-'0',c=getchar(); return x; } const int nmax=5005; int f[nmax],a[nmax],sum[nmax]; int main(){ int N=read(); rep(i,1,N) a[i]=read(),sum[i]=sum[i-1]+a[i]; rep(i,0,N-1) rep(j,1,N-i) { f[j]=max(sum[j+i]-sum[j-1]-f[j],sum[j+i]-sum[j-1]-f[j+1]); } printf("%d ",f[1]); return 0; }
bzoj2100:
两遍dijkstra就好了。。。
#include<cstdio> #include<cstring> #include<iostream> #include<algorithm> #include<queue> using namespace std; #define rep(i,s,t) for(int i=s;i<=t;i++) #define clr(x,c) memset(x,c,sizeof(x)) #define qwq(x) for(edge *o=head[x];o;o=o->next) const int nmax=100005; const int maxn=400005; const int inf=0x7f7f7f7f; int read(){ int x=0;char c=getchar(); while(!isdigit(c)) c=getchar(); while(isdigit(c)) x=x*10+c-'0',c=getchar(); return x; } struct edge{ int to,dist;edge *next; }; edge edges[maxn],*pt=edges,*head[nmax]; void add(int u,int v,int d){ pt->to=v;pt->dist=d;pt->next=head[u];head[u]=pt++; pt->to=u;pt->dist=d;pt->next=head[v];head[v]=pt++; } struct node{ int x,dist; node(int x,int dist):x(x),dist(dist){}; bool operator<(const node&rhs)const{ return dist>rhs.dist;} }; priority_queue<node>q; int dist[nmax]; void dijkstra(int s){ clr(dist,0x7f);dist[s]=0; q.push(node(s,0)); while(!q.empty()){ node o=q.top();q.pop(); int x=o.x,d=o.dist; if(dist[x]!=d) continue; qwq(x) if(dist[o->to]>d+o->dist) dist[o->to]=d+o->dist,q.push(node(o->to,dist[o->to])); } } int main(){ int N=read(),M=read(),s=read(),a=read(),b=read(); rep(i,1,N){ int u=read(),v=read(),d=read(); add(u,v,d); } dijkstra(a); int ans=dist[s]+dist[b]; dijkstra(b); ans=min(ans,dist[s]+dist[a]); printf("%d ",ans); return 0; }
❤bzoj2017:
神dp!!!用了和2101差不多的方法,还更神的压掉一维。。。
#include<cstdio> #include<cstring> #include<iostream> #include<algorithm> using namespace std; #define rep(i,s,t) for(int i=s;i<=t;i++) #define dwn(i,s,t) for(int i=s;i>=t;i--) int read(){ int x=0;char c=getchar(); while(!isdigit(c)) c=getchar(); while(isdigit(c)) x=x*10+c-'0',c=getchar(); return x; } const int nmax=2005; int a[nmax],sum[nmax],f[nmax][nmax]; int main(){ int n=read(); dwn(i,n,1) a[i]=read(); rep(i,1,n) sum[i]=sum[i-1]+a[i]; rep(i,1,n) rep(j,1,n){ f[i][j]=f[i][j-1]; if(i>=j+j) f[i][j]=max(f[i][j],sum[i]-f[i-j-j][j+j]); if(i>=j+j-1) f[i][j]=max(f[i][j],sum[i]-f[i-j-j+1][j+j-1]); } printf("%d ",f[n][1]); return 0; }
bzoj1673:
利用性质用dfs写背包dp(加了一个剪枝;
#include<cstdio> #include<cstring> #include<iostream> #include<algorithm> using namespace std; #define rep(i,s,t) for(int i=s;i<=t;i++) #define dwn(i,s,t) for(int i=s;i>=t;i--) #define ll long long #define clr(x,c) memset(x,c,sizeof(x)) const int nmax=1005; ll a[nmax],sum[nmax],ans=0,N,C; void dfs(int cur,ll x){ if(sum[cur-1]+x<=C) { ans=max(ans,sum[cur-1]+x); return ; } ans=max(ans,x); dwn(i,cur-1,1){ x+=a[i]; if(x<=C) dfs(i,x); x-=a[i]; } } int main(){ scanf("%lld%lld",&N,&C); rep(i,1,N) scanf("%lld",&a[i]),sum[i]=sum[i-1]+a[i]; dfs(N+1,0); printf("%d ",ans); return 0; }
bzoj2016:
裸的二分答案,输出方案我原来那样子写在最后还更新了一下答案!最后还更新了答案!!!没救了。。。
#include<cstdio> #include<cstring> #include<iostream> #include<algorithm> using namespace std; #define rep(i,s,t) for(int i=s;i<=t;i++) #define dwn(i,s,t) for(int i=s;i>=t;i--) #define clr(x,c) memset(x,c,sizeof(x)) #define ll long long ll read(){ ll x=0;char c=getchar(); while(!isdigit(c)) c=getchar(); while(isdigit(c)) x=x*10+c-'0',c=getchar(); return x; } const int nmax=50005; ll a[nmax],res[nmax],N,D; /*bool check(ll x){ ll cur=0,tmp=0; rep(i,1,D){ while(tmp<x&&cur<=N) tmp+=a[++cur],res[cur]=i; if(cur>N) return false; tmp/=2; } rep(i,cur+1,N) res[i]=D; return true; }*/ bool check(ll x){ ll cur=0,tmp=0; rep(i,1,D){ while(tmp<x&&cur<=N) tmp+=a[++cur]; if(cur>N) return false; tmp/=2; } return true; } void get(ll x){ ll cur=0,tmp=0; rep(i,1,D){ while(tmp<x) tmp+=a[++cur],res[cur]=i; tmp/=2; } rep(i,cur+1,N) res[i]=D; } int main(){ N=read(),D=read(); ll l=0,r=0; rep(i,1,N) a[i]=read(),r+=a[i]; ll mid,ans; while(l<=r){ mid=(l+r)>>1; if(check(mid)) ans=mid,l=mid+1; else r=mid-1; } get(ans); printf("%lld ",ans); rep(i,1,N) printf("%lld ",res[i]); return 0; } /* 5 5 10 40 13 22 7 */
bzoj2015:
dijkstra。。。
#include<cstdio> #include<cstring> #include<iostream> #include<algorithm> #include<queue> using namespace std; #define rep(i,s,t) for(int i=s;i<=t;i++) #define clr(x,c) memset(x,c,sizeof(x)) #define qwq(x) for(edge *o=head[x];o;o=o->next) int read(){ int x=0;char c=getchar(); while(!isdigit(c)) c=getchar(); while(isdigit(c)) x=x*10+c-'0',c=getchar(); return x; } const int nmax=50005; const int maxn=200005; const int inf=0x7f7f7f7f; struct edge{ int to,dist;edge *next; }; edge edges[maxn],*pt=edges,*head[nmax]; void add(int u,int v,int d){ pt->to=v;pt->dist=d;pt->next=head[u];head[u]=pt++; pt->to=u;pt->dist=d;pt->next=head[v];head[v]=pt++; } struct node{ int x,dist; node(int x,int dist):x(x),dist(dist){}; node(){}; bool operator<(const node&rhs)const{ return dist>rhs.dist;} }; priority_queue<node>q; int dist[nmax]; void dijkstra(){ clr(dist,0x7f);dist[1]=0; q.push(node(1,0)); int x,d; while(!q.empty()){ node o=q.top();q.pop(); x=o.x,d=o.dist; if(dist[x]!=d) continue; qwq(x) if(dist[o->to]>dist[x]+o->dist){ dist[o->to]=dist[x]+o->dist; q.push(node(o->to,dist[o->to])); } } } int main(){ int N=read(),M=read(),B=read(),u,v,d; rep(i,1,M){ u=read(),v=read(),d=read(); add(u,v,d); } dijkstra(); rep(i,1,B){ u=read(),v=read(); printf("%d ",dist[u]+dist[v]); } return 0; }
bzoj2014:
数据大唬人啊。。。然并卵。
#include<cstdio> #include<cstring> #include<iostream> #include<algorithm> using namespace std; #define rep(i,s,t) for(int i=s;i<=t;i++) #define clr(x,c) memset(x,c,sizeof(x)) #define ll long long ll read(){ ll _x=0;char _c=getchar(); while(!isdigit(_c)) _c=getchar(); while(isdigit(_c)) _x=_x*10+_c-'0',_c=getchar(); return _x; } const int nmax=100005; struct node{ ll w,c; bool operator<(const node&rhs)const{ return c<rhs.c;} }; node nodes[nmax]; int main(){ ll N=read(),m=read(); rep(i,1,N) nodes[i].c=read(),nodes[i].w=read(); sort(nodes+1,nodes+N+1); ll ans=0,tmp; rep(i,1,N){ tmp=min(m/nodes[i].c,nodes[i].w); ans+=tmp;m-=nodes[i].c*tmp; } printf("%lld ",ans); return 0; }
bzoj1689:
在枚举水坑的时候枚举木板就可以了
#include<cstdio> #include<cstring> #include<iostream> #include<algorithm> using namespace std; #define rep(i,s,t) for(int i=s;i<=t;i++) #define clr(x,c) memset(x,c,sizeof(x)) int _x;char _c; int read(){ _x=0;_c=getchar(); while(!isdigit(_c)) _c=getchar(); while(isdigit(_c)) _x=_x*10+_c-'0',_c=getchar(); return _x; } const int nmax=10005; struct node{ int l,r; bool operator<(const node&rhs)const{ return l<rhs.l||l==rhs.l&&r<rhs.r;} }; node nodes[nmax]; int main(){ int N=read(),L=read(); rep(i,1,N) nodes[i].l=read()+1,nodes[i].r=read(); sort(nodes+1,nodes+N+1); int cnt=(nodes[1].r-nodes[1].l)/L+1,cur=nodes[1].l+cnt*L-1,tmp; rep(i,2,N){ if(cur>=nodes[i].r) continue; if(nodes[i].l>cur){ tmp=(nodes[i].r-nodes[i].l)/L+1; cur=nodes[i].l+tmp*L-1;cnt+=tmp; }else{ tmp=(nodes[i].r-cur-1)/L+1; cur+=tmp*L;cnt+=tmp; } } printf("%d ",cnt); return 0; }
bzoj1688:
N很小很明显可以状压。然后位运算加括号加括号不然总是神奇的优先级啊。。。
#include<cstdio> #include<cstring> #include<iostream> #include<algorithm> using namespace std; #define rep(i,s,t) for(int i=s;i<=t;i++) #define clr(x,c) memset(x,c,sizeof(x)) int _x;char _c; int read(){ _x=0;_c=getchar(); while(!isdigit(_c)) _c=getchar(); while(isdigit(_c)) _x=_x*10+_c-'0',_c=getchar(); return _x; } const int nmax=1005; int N,D,K,a[nmax],t[16]; bool pd(int x){ int cnt=0; while(x) cnt+=x&1,x>>=1; return cnt<=K; } int main(){ N=read(),D=read(),K=read(); int u,v; rep(i,1,16) t[i]=1<<(i-1); rep(i,1,N){ u=read(); rep(j,1,u) v=read(),a[i]|=t[v]; } int ans=0,sum,tmp=(1<<D)-1; rep(i,0,tmp) if(pd(i)){ sum=0; rep(j,1,N) if((i|a[j])==i) sum++; ans=max(ans,sum); } printf("%d ",ans); return 0; } /* 6 3 2 0 1 1 1 2 1 3 2 2 1 2 2 1 */
bzoj1684:
暴力!模拟!
#include<cstdio> double as(double x){ return x<0?-x:x; } int main(){ int N,D; scanf("%d%d",&N,&D); double ans=2.0,tmp=N*1.0/D; int ta,tb,temp; for(int i=1;i<=32767;i++){ temp=tmp*i; if(as(tmp-temp*1.0/i)<ans&&i*N!=D*temp) ans=as(tmp-temp*1.0/i),ta=temp,tb=i; if(as(tmp-(temp+1)*1.0/i)<ans&&i*N!=D*(temp+1)) ans=as(tmp-(temp+1)*1.0/i),ta=temp+1,tb=i; } printf("%d %d ",ta,tb); return 0; }
bzoj1682:
二分答案+spfa。。。。我。。。
#include<cstdio> #include<cstring> #include<iostream> #include<algorithm> #include<queue> using namespace std; #define rep(i,s,t) for(int i=s;i<=t;i++) #define dwn(i,s,t) for(int i=s;i>=t;i--) #define clr(x,c) memset(x,c,sizeof(x)) #define qwq(x) for(edge *o=head[x];o;o=o->next) const int nmax=2005; const int maxn=20005; const int inf=0x7f7f7f7f; int read(){ int x=0;char c=getchar(); while(!isdigit(c)) c=getchar(); while(isdigit(c)) x=x*10+c-'0',c=getchar(); return x; } struct edge{ int to,dist; bool flag; edge *next; }; edge edges[maxn],*pt=edges,*head[nmax]; void add(int u,int v,int d){ pt->to=v;pt->dist=d;pt->next=head[u];head[u]=pt++; pt->to=u;pt->dist=d;pt->next=head[v];head[v]=pt++; } int N,M; int q[nmax]; bool inq[nmax]; int dist[nmax]; bool spfa(){ clr(inq,0);inq[1]=1; int x,l=1,r=1;q[1]=1; clr(dist,0x7f);dist[1]=0; while(l<=r){ x=q[l];l++; qwq(x) if(o->flag&&dist[o->to]>dist[x]+o->dist){ dist[o->to]=dist[x]+o->dist; if(!inq[o->to]) q[++r]=o->to,inq[o->to]=1; } } rep(i,1,N) if(dist[i]==inf) return false; return true; } bool check(int x){ rep(i,1,N) qwq(i) if(o->dist<=x) o->flag=true; else o->flag=false; if(spfa()) return true; return false; } int main(){ N=read(),M=read(); int u,v,d,omax=0; rep(i,1,M){ u=read(),v=read(),d=read();add(u,v,d); omax=max(omax,d); } int l=0,r=omax,mid,ans=0; while(l<=r){ mid=(l+r)>>1; if(check(mid)) ans=mid,r=mid-1; else l=mid+1; } printf("%d ",ans); return 0; }
bzoj1649:
找出每一段使用的次数就可以了。(分成两半想。。不然会乱死。。。
#include<cstdio> #include<cstring> #include<iostream> #include<algorithm> using namespace std; #define rep(i,s,t) for(int i=s;i<=t;i++) #define ll long long const int nmax=10005; int a[nmax]; int main(){ int n;scanf("%d",&n); rep(i,1,n) scanf("%d",&a[i]); sort(a+1,a+n+1); ll ans=0; rep(i,1,n-1) ans+=(ll)i*(n-i)*(a[i+1]-a[i]); printf("%lld ",ans<<1); return 0; }
bzoj1677:
背包dp。。。我。。。
#include<cstdio> #include<cstring> #include<iostream> #include<algorithm> using namespace std; #define rep(i,s,t) for(int i=s;i<=t;i++) #define clr(x,c) memset(x,c,sizeof(x)) int a[25],dp[1000005]; int main(){ int n;scanf("%d",&n); rep(i,0,25){ if((1<<i)>n) break; a[++a[0]]=(1<<i); } dp[0]=1; rep(i,1,a[0]) rep(j,a[i],n) if((dp[j]+=dp[j-a[i]])>=1000000000) dp[j]-=1000000000; printf("%d ",dp[n]); return 0; }
bzoj1671:
两遍bfs就可以了(看清题意看清题意。。。
#include<cstdio> #include<cstring> #include<iostream> #include<algorithm> #include<queue> using namespace std; #define rep(i,s,t) for(i=s;i<=t;i++) #define clr(x,c) memset(x,c,sizeof(x)) int read(){ int x=0;char c=getchar(); while(!isdigit(c)) c=getchar(); while(isdigit(c)) x=x*10+c-'0',c=getchar(); return x; } const int nmax=1005; const int maxn=1000005; int map[nmax][nmax],oa[maxn],ob[maxn]; int dist[nmax][nmax],dis[nmax][nmax]; bool vis[nmax][nmax]; int q[maxn],Q[maxn]; int xx[5]={0,0,0,1,-1}; int yy[5]={0,1,-1,0,0}; int main(){ int n,m,i,j,sa,sb,ta,tb,cnt=0; m=read(),n=read(); rep(i,1,n) rep(j,1,m){ map[i][j]=read(); if(map[i][j]==2) sa=i,sb=j; else if(map[i][j]==3) ta=i,tb=j; else if(map[i][j]==4) oa[++cnt]=i,ob[cnt]=j; } int x,y,tx,ty,l,r; q[l=r=1]=sa;Q[l]=sb; vis[sa][sb]=1;map[ta][tb]=1; clr(dist,0x3f);dist[sa][sb]=0; while(l<=r){ x=q[l];y=Q[l];l++; rep(i,1,4){ tx=x+xx[i],ty=y+yy[i]; if(tx<1||ty<1||tx>n||ty>m||map[tx][ty]==1||vis[tx][ty]) continue; vis[tx][ty]=1;dist[tx][ty]=dist[x][y]+1; q[++r]=tx;Q[r]=ty; } } q[l=r=1]=ta;Q[l]=tb; clr(vis,0);vis[ta][tb]=1; clr(dis,0x3f);dis[ta][tb]=0; while(l<=r){ x=q[l];y=Q[l];l++; rep(i,1,4){ tx=x+xx[i],ty=y+yy[i]; if(tx<1||ty<1||tx>n||ty>m||map[tx][ty]==1||vis[tx][ty]) continue; vis[tx][ty]=1;dis[tx][ty]=dis[x][y]+1; q[++r]=tx;Q[r]=ty; } } int ans=0x7fffffff; rep(i,1,cnt) ans=min(ans,dist[oa[i]][ob[i]]+dis[oa[i]][ob[i]]); printf("%d ",ans); return 0; }
bzoj1665:
转换成最短路就可以了。
#include<cstdio> #include<cstring> #include<iostream> #include<algorithm> #include<queue> using namespace std; #define rep(i,s,t) for(int i=s;i<=t;i++) #define clr(x,c) memset(x,c,sizeof(x)) #define qwq(x) for(edge *o=head[x];o;o=o->next) int read(){ int x=0;char c=getchar(); while(!isdigit(c)) c=getchar(); while(isdigit(c)) x=x*10+c-'0',c=getchar(); return x; } const int nmax=10005; const int maxn=2000005; const int inf=0x7f7f7f7f; struct edge{ int to,dist;edge *next; }; edge edges[maxn],*pt=edges,*head[nmax]; void add(int u,int v,int d){ pt->to=v;pt->dist=d;pt->next=head[u];head[u]=pt++; pt->to=u;pt->dist=d;pt->next=head[v];head[v]=pt++; } int H,N,s,t; queue<int>q; int dist[nmax],x[nmax],y[nmax]; bool inq[nmax]; void spfa(){ clr(dist,0x7f);dist[0]=0; clr(inq,false);q.push(0); while(!q.empty()){ int x=q.front();q.pop();inq[x]=false; qwq(x) if(dist[o->to]>dist[x]+o->dist){ dist[o->to]=dist[x]+o->dist; if(!inq[o->to]) q.push(o->to),inq[o->to]=true; } } printf("%d ",dist[t]-1); } int main(){ H=read(),N=read(),s=0,t=N+1; rep(i,1,N) { x[i]=read(),y[i]=read(); if(y[i]<=1000) add(s,i,1); if(H-y[i]<=1000) add(i,t,1); rep(j,1,i-1) if((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j])<=1000000) add(i,j,1); } spfa(); return 0; }
bzoj1672:
更区间覆盖差不多。。改一下就可以了。挖坑!有比O(n2)的方法!
#include<cstdio> #include<cstring> #include<iostream> #include<algorithm> using namespace std; #define rep(i,s,t) for(int i=s;i<=t;i++) #define clr(x,c) memset(x,c,sizeof(x)) int read(){ int x=0;char c=getchar(); while(!isdigit(c)) c=getchar(); while(isdigit(c)) x=x*10+c-'0',c=getchar(); return x; } const int nmax=10005; const int inf=0x7f7f7f7f; struct node{ int l,r,c; bool operator<(const node&rhs)const{ return l<rhs.l||l==rhs.l&&r<rhs.r;} }; node nodes[nmax]; int dp[nmax]; int main(){ int n=read(),s=read(),t=read(); rep(i,1,n) { node &o=nodes[i]; o.l=read(),o.r=read(),o.c=read(); } sort(nodes+1,nodes+n+1); if(nodes[1].l>s) { printf("-1 ");return 0; } int ans=inf; clr(dp,0x7f); rep(i,1,n) { if(nodes[i].l<=s) dp[i]=nodes[i].c; rep(j,1,i-1) if(dp[j]!=inf&&nodes[i].l<=nodes[j].r+1) dp[i]=min(dp[i],dp[j]+nodes[i].c); if(nodes[i].r>=t) ans=min(ans,dp[i]); } if(ans==inf) ans=-1; printf("%d ",ans); return 0; } /* 3 0 4 0 2 3 3 4 2 0 0 1 */
bzoj1664:
同前一题
#include<cstdio> #include<cstring> #include<iostream> #include<algorithm> using namespace std; #define rep(i,s,t) for(int i=s;i<=t;i++) #define clr(x,c) memset(x,c,sizeof(x)) int read(){ int x=0;char c=getchar(); while(!isdigit(c)) c=getchar(); while(isdigit(c)) x=x*10+c-'0',c=getchar(); return x; } const int nmax=10005; struct node{ int l,r; bool operator<(const node&rhs)const{ return l<rhs.l||l==rhs.l&&r<rhs.r;} }; node nodes[nmax]; int dp[nmax]; int main(){ int n=read(); rep(i,1,n) { node &o=nodes[i]; o.l=o.r=read(),o.r+=read()-1; } sort(nodes+1,nodes+n+1); int ans=1; rep(i,1,n) { dp[i]=1; rep(j,1,i-1) if(nodes[i].l>nodes[j].r) dp[i]=max(dp[i],dp[j]+1); ans=max(ans,dp[i]); } printf("%d ",ans); return 0; }
bzoj1662:
!!!打表第一个元素为0,打表第一个元素为0,打表第一个元素为0!!!哦一开始的表还打不完整,可以同时打两个表然后一个输出编号。那么就可以判断打的完不完整啦。。。
#include<cstdio> #include<cstring> #include<iostream> #include<algorithm> #define rep(i,s,t) for(int i=s;i<=t;i++) const int a[]={0,98891,94198,95493,107314,87316,114008,102469,74236,81159,56924,101809,143253,116151,126639,96187,88604,109609,92456,80718,69276,40647,162224,131672,118369,107427,85088,115982,100747,74503,80467,56901,90275,106606,73627,91132,57627,60303,68604,56911,50224,36158,25284,182796,162761,151564,143141,122235,147485,137996,112969,116985,92987,118295,143177,110808,128802,93230,92122,107984,92379,83907,66388,47099,159532,131378,118327,106305,80363,120639,98568,77976,74374,56700,94413,105948,69499,91945,57927,63850,69546,52748,51296,34407,34730,181177,162526,150415,143712,118099,152204,135651,114195,112068,92595,123204,142014,106644,131594,93792,96040,107083,87035,86134,63474,54978,155225,131401,118634,106767,75572,124211,96292,79755,70148,56243,97011,107586,70853,90733,57056,65433,69447,48145,53132,32025,43582,154467,130916,118508,106264,73367,126794,94239,80429,68353,57400,100958,106012,71604,87519,57572,66722,68874,46056,53415,32182,44814,116453,92806,81294,68677,38324,91605,56472,49323,38518,26743,75081,65806,41655,49212,28901,40659,36969,20942,28038,12701,48768,191146,183448,175274,170660,144282,181071,163294,151722,143637,128215,155597,170036,144933,157346,130629,131128,143583,117216,126583,96530,94970,175318,161924,150364,142014,107487,162841,131772,118795,106712,86938,137207,139655,110863,119575,93918,101314,106872,74787,90574,58392,77998,173327,161517,150494,143557,108365,161790,131378,118559,107306,83653,140360,137876,112471,118470,93274,102168,105843,73340,91392,57145,79091,142486,131788,119509,105816,73165,126604,93786,81687,68979,45646,116163,99891,76912,76111,56409,71596,68496,38005,56106,28712,75237,171313,162188,152366,141097,111110,158835,131071,118011,106090,80018,147115,136526,113900,112986,92967,103988,106200,68484,93243,57896,85415,143704,127431,121422,103119,77086,121899,92512,82512,69119,42360,122159,95976,79714,71293,56364,72488,68224,39380,55185,29396,78322,143244,125731,122087,101509,79241,119666,93681,81638,68817,40477,124806,95241,80022,69266,56160,75022,68634,40038,52425,28887,72408,107048,83085,87067,61933,52320,78065,56852,48415,37218,17262,90792,57131,48172,38127,28227,47200,35388,19556,23969,12007,91618,188003,179364,178374,167810,148695,177440,161855,151351,142818,108805,179486,162007,151810,143741,129537,141233,141251,109889,123713,93373,118608,170818,154340,156776,136190,118835,149288,130700,117473,105857,68125,162887,132023,118909,107313,87337,114058,102545,74125,81355,56783,109233,171190,152382,157609,134608,121075,146531,130574,116961,106606,71127,162240,131756,118473,107266,85298,115808,100887,74530,80460,56937,104744,143028,113112,128214,94751,90628,107060,92723,83137,68117,43228,127887,93540,82276,68663,46915,83876,62214,45435,42578,28802,111407,170911,147903,159816,131582,124710,143681,131020,119783,105004,74840,159737,131288,118327,106445,80258,120527,98827,77829,74534,56666,111270,142384,108398,129294,93814,95121,107398,89760,84594,65532,49355,123350,92952,80924,69825,43486,87894,59398,46563,39612,28742,109612,142175,106368,131638,94003,95864,107104,87175,86044,63529,52732,120317,93533,82220,68803,41452,88912,58860,47529,37969,28687,92365,107623,70818,90839,57161,65201,69588,48279,53095,32055,35207,79780,56684,48851,37003,17741,55657,29110,24270,16366,12188,127716,170972,144090,160466,131687,129365,143246,121634,123066,100633,86300,152593,130881,117493,106712,71152,128330,92901,81592,70190,54772,124627,141867,109152,125487,93093,98756,106214,80363,89123,60436,62379,113484,93274,81246,68242,37246,91936,58406,49636,37915,25000,125906,141143,110126,122782,92694,99695,107349,77610,90055,59005,65659,111535,92462,80994,67849,38982,93037,57378,49229,37299,23948,108481,101761,74481,80118,57538,69760,68853,40959,55474,29621,46335,69908,56198,49191,37488,20207,53469,28961,24876,16726,8018,134641,137953,112241,118736,93113,102168,106032,73318,91371,57202,71593,105908,94057,83424,67403,43061,87281,57217,48837,37410,21019,114520,100017,76814,76343,56423,71449,68601,38040,56085,28742,50846,70014,54232,51212,34234,24847,48630,28916,24419,16474,7466,118105,98168,77949,73627,56606,71930,68299,37034,56985,29726,52489,69888,51438,52150,33652,26250,46540,28742,24988,16620,6629,87869,58665,47562,38597,28732,43746,36970,18455,27300,12200,34405,37536,23384,27054,13648,13716,20914,12052,10145,5787,1649,181212,195180,188899,189346,182615,181348,188064,171340,183040,162686,159299,188058,181141,177205,167596,148246,178641,162701,151002,142596,111997,185183,184527,174229,170777,163010,164492,170904,144149,159881,131637,135607,171039,155170,156173,137655,117048,151608,130195,118445,106264,70098,188817,182976,175701,171305,162023,165413,170049,144814,158343,131232,137303,170782,154417,156707,136385,118724,149274,130840,117423,105837,68295,183061,163196,151645,143583,126716,143829,140518,110365,121347,92657,114542,143379,116397,126554,96166,88408,109883,92609,80761,68911,40398,194177,183680,175565,171120,159238,167988,168828,145597,154708,131399,140921,171039,149534,159445,133395,122791,144192,129930,119346,106573,72729,182905,162670,151598,143253,122586,147289,137801,112898,117216,93162,118170,142945,111235,128627,93427,92036,107578,92709,83816,66570,46982,182208,162877,151156,143099,119581,150256,137298,113599,114408,92881,120741,142518,108524,129272,93625,95045,107391,90060,84489,65532,50539,157913,130952,117522,107363,78633,122417,97315,77976,73220,56417,95822,105752,68548,93676,57644,64725,69125,50726,52519,32876,39531,192875,183194,175618,171049,151952,174934,165698,148719,146250,130202,148526,171003,143872,162158,131638,128107,143712,124534,122695,100515,84414,179046,162855,151276,142818,113041,156547,132688,116751,106534,93340,127952,142868,108643,127340,93827,97721,106767,82007,87039,62536,63943,178167,162511,150436,143337,110394,158654,131204,117287,107834,91993,130682,141895,109097,125682,92932,98917,106264,80264,89152,60491,66418,150200,131007,117830,106053,69168,129082,94597,82808,69636,52286,106611,103861,73537,83050,56487,68270,69462,43084,55140,30017,59453,175466,161826,150784,142014,107006,162965,131702,118845,107033,86979,136851,139775,110771,119652,94093,101229,106796,75166,90286,58595,74658,145788,129951,117384,107332,71505,129461,93449,82080,69426,47744,113197,99962,75939,79213,56747,70376,68341,39972,55857,29082,66099,142469,131891,119417,105907,73018,126675,93918,81918,68944,45795,115587,100122,76954,76370,56445,71385,68587,38124,56095,28742,62155,107819,91321,84173,65639,45576,85123,56852,48563,36810,20953,86031,60233,46319,40126,28831,43534,36951,16387,29092,12407,75005,188069,182810,176152,170005,145487,180802,162231,151085,143547,117061,169502,165977,148361,147785,130419,136079,141552,108107,130950,93891,110339,171050,159631,153864,139529,113383,154616,131680,118228,106957,74457,153133,134018,115721,108224,92158,106987,107092,70938,89724,56762,97111,171205,157828,154565,137373,116114,153809,131036,118046,106068,72771,156296,132310,116667,106514,93556,108895,105726,71771,87085,57146,94333,143294,120178,124796,99646,83556,115429,92497,81834,68391,37884,128652,92420,83325,69868,53770,78624,65371,42090,48265,28951,96888,170732,154481,156741,136491,118563,149379,130861,117388,105956,68361,162301,132094,118838,107383,87632,113818,102791,73964,81684,56420,101542,143429,116473,126604,96116,88255,110177,92608,80727,68750,40203,130204,94157,81974,69280,49233,82328,62822,43379,45397,28997,98039,143126,113315,128172,95011,90312,107382,92240,83285,68368,42746,128278,93303,82317,68978,47015,83762,62179,45274,42739,28960,86196,106460,72092,91538,56834,61041,69861,55983,50798,35141,25858,86923,56937,48773,37089,20893,53205,31178,23246,18088,11976,113496,170799,145572,160459,130970,127512,143584,129334,120426,103723,77428,157983,130972,117683,107167,78801,122299,97405,77962,73333,56423,113876,142301,106014,131852,94108,95668,107244,87246,85959,63775,52430,120675,93245,82296,68678,41853,88882,58790,47599,38012,28688,111763,143160,108085,129972,93751,96011,107588,84871,86688,62401,55088,119634,93358,81814,68446,40092,90481,57422,48134,37026,29202,96491,106075,71702,88142,57300,66687,68803,46457,53171,32396,38222,77092,56571,48250,37447,16968,55987,28808,24679,17489,10712,119854,142043,108935,125795,93127,98722,106354,80314,89047,60526,62205,113826,93091,81366,68208,37388,91872,58152,49671,38041,25148,103828,104065,73502,83106,56565,68031,69532,43267,55098,30052,43580,72519,56288,48407,36751,17901,56480,29276,24882,16576,9004,107497,101852,74356,80407,57515,69654,68909,41143,55199,29904,46178,70013,56251,48711,37670,20291,53624,28974,24835,16739,8083,81150,62008,44521,44278,28886,42697,36961,17739,28588,12020,29345,36876,29401,25792,15368,10469,24145,12152,10178,5807,2108,163606,195621,188546,191996,183302,179286,188002,174162,181454,162602,156847,188080,183336,175949,170385,144860,181933,162596,151141,142623,119792,174257,186342,172927,176046,162791,161179,170632,144079,160982,132144,132208,171270,160985,152855,141043,111646,157241,130594,118195,107314,77308,174319,185758,173313,175161,161965,161915,170044,143603,162790,131779,132975,171042,159781,153793,139565,113312,154609,131666,118425,106907,74584,170321,165490,148648,145446,129831,137679,143522,108116,128974,93373,107455,143513,123370,123031,99529,82013,118357,93184,81421,68243,39696,183060,184561,174257,170646,163030,164518,170918,144108,160014,131644,135449,171197,155492,155703,137929,116774,151797,130553,118187,106340,70343,178443,161979,151676,143755,129811,141065,141139,109951,124372,93274,111287,142626,119382,125609,98078,85565,112915,92932,80951,68243,36980,182422,163249,151602,143583,127285,143303,140658,110274,121710,92364,114457,143429,116635,126568,96081,88283,110311,92587,80769,68476,40226,162476,131848,118544,107041,85901,115212,101370,74643,80313,57097,89687,106627,74085,91235,57781,59889,69071,56143,50399,36684,24098,194088,183425,175662,171177,157499,169482,167668,146816,153296,131217,142364,170763,148423,159423,132080,124590,143132,131353,119558,105270,74872,182209,162884,151254,143099,119476,150326,137494,113368,114877,92623,120586,142783,108679,129216,93198,95016,107503,90411,84454,65442,50599,181268,162763,150771,143118,118819,151589,136015,114026,112699,92686,122560,142336,105844,131967,94198,95473,107349,87301,85889,63979,54109,155911,130777,118789,106768,76349,124057,96172,79644,70574,56295,96755,106921,70784,91245,57237,65020,69678,48651,52948,32219,43687,179198,162862,151178,143077,113041,156281,133214,116491,106800,93004,127712,142967,108622,127698,93610,97707,106705,82371,87130,62409,62020,152867,130987,117472,106873,71510,128013,93189,80745,70413,55395,103451,104906,72010,86328,56845,67506,68341,45412,54521,30852,52088,150563,130770,118011,105928,69477,129102,94136,82884,69587,52692,106302,103904,73502,83295,56543,67787,69734,43338,55063,30096,51432,112047,92553,81169,67878,38111,93507,57182,49636,37453,23962,79570,63494,43106,45473,29356,42194,37355,18291,28302,12362,58670,189899,182860,174295,171303,143913,183269,162995,151195,143585,124105,160566,168344,145867,154445,130938,133397,142818,112699,128375,94219,101694,171186,162567,151849,142847,109110,160205,131848,118543,106796,81601,142547,138287,113018,116473,92771,102811,106642,70927,91892,56471,86337,171324,162249,152457,141734,110321,159302,131036,118046,106264,80404,146309,136772,113795,113154,93366,104030,106054,68915,92308,58168,84986,143636,128174,120756,103554,76720,122607,92701,81855,69391,42739,121619,96530,79090,71973,56364,72375,67814,39132,55808,29396,82296,171081,159839,153758,139614,113242,154575,131798,118453,106872,74746,152600,134277,115687,108524,92201,106404,107225,70785,90173,56880,91096,143547,123496,122941,99759,81740,118470,93239,81492,68011,39971,126600,93959,80646,68440,57138,76403,67368,40626,50711,29136,85576,143309,120584,124335,99841,83269,115856,92623,81673,68496,37983,128433,92521,82988,69909,54106,78393,65231,42391,48413,28908,77323,106111,79955,89292,60205,55785,73606,56571,48279,36968,16368,93263,57931,49320,37929,24461,49978,33463,21031,21359,11922,98049,171206,152781,157603,134376,120998,147434,130343,117192,105717,70950,162591,131813,118558,106985,86103,115094,101524,74572,80314,57146,103812,143253,113743,127884,95206,89956,107803,92052,83072,68614,42367,128587,93036,82619,69084,47133,83699,61948,45134,43197,28951,101441,142791,111802,128235,93932,91923,106885,93276,83418,66961,45386,126408,93520,81723,68677,45245,85986,61263,45897,41072,28780,88686,106229,70013,91902,56938,63668,69805,53553,51288,34366,29162,83869,56901,48409,37707,19996,54065,30379,23371,17732,11932,106879,142391,105964,131777,94248,95473,107278,87372,86029,64006,51947,121102,92909,82332,68922,42009,88789,58804,47529,38139,28719,92311,106621,70818,91371,57223,65125,69567,48784,52941,32254,34193,80475,56922,48767,37110,17798,55501,29249,24286,16388,12095,94420,106411,71534,88500,57159,66616,68678,46858,53185,32282,38026,77253,56571,48408,37394,17021,55970,28825,24297,17784,10799,73104,66444,40871,50053,28959,40713,37011,20900,28031,12752,25302,40642,28895,24420,16347,5786,28663,12546,10488,5976,2756,143582,187650,171689,181214,162547,157785,171256,153852,157126,135734,121437,175689,162211,150630,142140,106426,163028,131854,118958,107139,87140,150016,169325,145428,155366,131239,132417,143169,115479,126694,96292,94743,146208,130112,116631,107679,71246,129713,93701,81743,69532,48272,150203,168483,145718,154504,131098,133243,142868,112860,128214,94309,98098,143099,131169,119410,106041,72766,127108,93988,81989,68909,46148,139147,138402,113018,116473,92932,102615,106662,71146,91870,56485,73639,107833,91664,84370,65897,44862,85795,56712,48676,36961,20942,158456,167308,147333,149947,131168,135065,142566,107480,129302,94765,103600,143601,128377,120595,103554,76791,122747,92672,81729,69441,42822,147907,135146,114763,111500,92462,104780,105508,69956,92996,57363,78398,106873,86909,86149,63348,49119,80153,57482,48893,37355,18117,150886,134305,115827,108629,92167,106138,107295,70763,90376,56916,80688,107314,83743,86905,61917,51784,78898,56788,48599,36847,17731,126340,94058,80568,68223,57426,76256,67423,40626,50747,29150,58231,68979,45681,53986,31761,30863,41973,28742,24528,16420,5836,177783,162386,151134,143784,129987,140903,141307,109791,124792,93184,111055,142471,119733,125589,98168,85404,113006,92987,81072,68305,37027,161396,132137,118796,107657,88198,113056,103273,73607,82209,56417,87638,107153,77092,89950,58658,58200,71412,56372,48242,37005,19742,162625,131813,118684,106846,86257,115149,101510,74551,80314,57182,89273,106985,74275,90960,58055,59580,69337,56197,50079,36851,23222,128728,93015,82695,69084,47218,83664,61828,45219,43295,28944,64909,68439,39379,55867,29027,35720,37988,28345,25847,15157,19250,159881,131616,118166,106627,80520,120070,99379,77396,75396,56258,94014,106284,70056,91929,56672,63766,69833,53665,51275,34337,31478,123951,93289,81282,69005,44319,87207,59980,46354,39999,28760,67436,68046,36905,57493,29480,38506,37734,24110,27079,13879,27690,121312,92713,82402,69063,42044,88732,58805,47494,38216,28742,68045,68952,39450,54554,29250,38982,37915,22836,27200,13482,26568,80440,56936,48794,37117,17806,55515,29257,24243,16432,12079,44273,36523,19344,24703,12144,20821,16455,7928,11465,4433,38251,178264,162742,150736,143001,111179,158009,131688,116786,107613,92694,129841,142303,108637,126289,93379,98350,106565,80243,88851,60982,65605,150850,130679,118061,105885,69858,129029,93681,82989,69525,53056,106140,103869,73431,83527,56642,67598,69678,43625,54971,30195,55828,149112,130574,117493,105717,68606,131647,94156,82597,69084,50747,109556,101943,74566,80794,57149,69689,68748,41592,55195,29944,55025,109287,92357,80605,69684,40470,91000,57132,48739,38014,22472,81375,62262,43925,44795,28896,42758,36990,17762,28587,12022,59007,143288,130916,119397,106068,72765,127320,93827,82080,68873,46288,114631,100494,76919,76825,56537,70818,68852,38481,56104,28770,60940,107835,91930,84264,65982,44666,85977,56621,48837,36968,20900,85617,60471,46087,40468,28949,43482,36951,16452,28663,12687,59127,107454,89227,84594,65336,46956,83065,56466,48811,37789,19283,87617,59068,47034,39134,28716,43725,36750,17838,28129,12163,49480,69084,50466,52540,32827,27396,45174,29438,24593,16539,6332,54913,29713,24085,16667,11920,23114,16558,7200,9996,3925,75508,143576,123651,123101,99962,81166,118897,93113,81527,68285,39971,126291,94219,80547,68032,57623,76145,67444,40660,50747,29200,74215,106872,81181,87843,62026,53496,76349,56451,48679,37095,16784,91572,56419,49776,38412,26526,48257,34361,20665,22658,11989,73699,105802,80524,89193,60211,55723,73647,56614,48408,36952,16386,92838,58021,49328,38132,24583,49731,33658,20905,21529,11932,58566,69300,42501,55108,29876,34128,38653,28732,24319,16347,8656,55451,29291,24747,16686,8674,26491,13649,8736,7628,3936,79428,106977,74415,90876,58126,59398,69541,56198,49874,37040,22181,89689,56747,49516,37503,21868,51652,31890,22732,19492,11995,62598,68368,39450,55910,29028,35682,37806,28542,25728,15297,13944,50550,29102,24518,16456,7630,27528,12965,9638,6387,3911,63625,68391,37877,56121,28864,37938,38196,26112,26336,14530,16574,48202,28951,24375,16800,7139,27846,12648,9747,6199,3913,41117,36839,16366,29355,12253,19890,16775,9092,11389,4533,10371,21200,12015,10304,5809,1729,11813,4014,3337,1549,971,129019,198962,196089,198455,194267,190474,196077,193723,190264,187196,172415,197897,194254,189824,188003,176262,189022,185190,173850,172391,161205,172833,196087,188082,194078,183435,177876,188048,180979,177211,167759,148717,192072,183573,175253,170769,148296,178261,163533,149861,143323,131197,161219,196063,188102,193782,183587,177943,187994,179057,178673,167662,149396,191677,183025,175409,170793,145522,180452,162318,151810,143584,129292,161069,187640,171699,181257,162547,158016,170982,154035,157035,135931,121201,175855,162266,150574,142301,106036,163123,131939,118937,107229,87211,158801,195952,188204,192911,183158,178879,188002,177806,179340,165627,152290,189986,182938,174600,170843,143892,183325,163031,151163,143692,124680,166745,187078,171966,179132,162827,159527,170969,149484,159263,132898,126795,171738,161936,151828,142870,109100,160718,131470,118705,106761,82118,164805,186550,172691,178204,162547,159737,171204,147519,159942,131351,129446,171332,162612,152156,142028,109968,159509,131098,118397,106319,80314,161491,167330,147423,150311,130931,135079,142496,107838,129252,94437,103445,143635,128644,120287,104023,76469,122908,92932,81308,69482,43261,174536,195440,188639,190775,183070,180341,187650,170799,183623,163041,158438,188048,182224,176673,169310,146202,179406,162875,151450,143219,115129,179988,185568,173685,173564,161763,162298,171258,143923,161987,131428,133868,171258,158146,154635,138149,114906,154346,131015,118228,106228,73382,182473,184668,174174,170911,162861,164341,170963,144106,160030,131903,135322,171058,156220,154967,138084,116714,152417,130574,117865,106606,70665,177771,162602,150677,143795,130105,140854,141608,109454,125115,93163,110859,142588,119777,125554,98294,85172,113077,93212,81190,68264,37114,191711,183700,175679,171270,160985,166244,170026,144815,157261,130574,138784,171251,152985,157533,134930,120325,147960,130363,117277,105283,70696,183565,163076,151557,143143,126168,144627,139565,110912,119616,93772,115473,143303,114260,127422,95599,89375,108461,92166,82258,69096,42136,183092,162842,151463,143491,123370,146624,137526,112822,118316,93169,117546,142470,112368,128390,94009,91657,106323,93642,83424,67333,45463,159992,131659,118074,106985,80710,119501,99799,77074,75718,56416,93695,106305,70337,91887,56265,63823,69888,53889,51303,34261,32788,198328,194201,189811,187805,179045,186514,186284,172942,176008,162526,165976,187912,171438,182676,163248,156258,171258,160508,153331,140602,112931,193140,182987,175624,171205,152634,174381,165586,148683,147217,130434,147993,170149,143869,162454,131828,128161,143307,125543,122100,101335,83552,192373,183625,175425,171040,150051,176663,165061,149077,144514,129501,151393,171182,143941,161326,131058,129356,143394,122782,123137,99849,86930,178428,162757,150876,142806,111535,157652,132024,116813,107152,93079,129448,142373,108805,126373,93429,98259,106586,80103,89152,61087,67280,191721,182984,175449,170850,145662,180326,162205,151810,143669,129376,154511,170077,144822,158019,131148,130436,143175,118777,125784,97511,93117,175869,162302,150574,142356,105866,163182,131974,118860,107327,87301,135898,140321,110611,120786,93169,101068,106712,76349,90084,58783,75953,174028,161986,149986,142986,108185,162195,131693,118313,107447,85033,138979,138822,110913,119797,93394,101817,106530,73612,91161,57569,77456,143610,130559,119327,106124,72758,127683,93590,82261,68748,46597,114574,100262,76843,77112,56607,70594,68971,38639,56066,28808,74500,188081,183540,175774,170662,144554,182049,162833,151276,142839,119736,166000,167321,147466,150522,130770,135085,142461,108006,129329,94171,107899,171260,161511,152492,141307,111395,157737,130826,117446,107565,78177,148901,135580,114266,112032,92512,104857,105556,69185,93466,57223,92169,171204,159874,153758,139810,112933,155170,131477,118593,106817,75466,151654,134719,115672,108959,92308,105224,107542,70833,90733,57021,90071,143585,124064,123017,100159,80660,119191,92988,81848,68335,39993,126164,94219,80386,68352,57464,75858,67675,40535,50830,29438,90588,171084,156354,154799,138245,116568,152515,130735,117633,106677,70870,158337,130889,117897,107826,91476,110611,104311,72696,85592,56747,96602,142776,119777,125393,98455,85047,113097,93373,81226,68200,37201,129553,94618,82703,69692,51866,79835,65029,42376,46979,28750,92578,143570,117201,126533,96489,87497,111270,92518,80916,67792,39475,131098,93996,82296,68622,50466,81928,63214,43323,45292,29158,82694,106852,74724,90672,58307,59140,69865,56199,49485,37272,21733,90116,56873,49355,37608,21967,51575,31878,22688,19634,11988,111905,196010,190944,192249,184548,175664,187794,183656,175725,170919,144334,193800,183634,175493,171127,155639,170983,167982,146861,152009,130503,148286,187992,173929,181328,162176,155832,171313,162159,152387,141105,111496,181736,162618,151085,142536,119416,151294,136526,113845,113006,92952,137177,187892,171599,182480,163242,156255,171295,160621,153191,140797,112556,180544,162071,151470,143442,116781,153220,134397,115603,110450,92553,135728,170015,143868,162569,131828,128056,143307,125703,122002,101524,81922,154638,131624,118130,106768,74162,125893,95165,80078,69210,56152,137816,188056,171348,183016,162569,157225,171197,157542,154655,137576,117511,178563,162716,150847,142785,111767,157386,132290,116792,106920,93241,141928,170816,144198,159874,131504,129646,143120,119694,125342,99338,87760,151370,130307,118313,106214,70007,128902,92994,83052,69749,53553,139665,170090,144815,158027,131336,130436,142971,118981,125659,97587,90815,149268,130650,117528,105802,68096,131834,94233,82486,69371,50802,130984,140321,110540,121046,92944,101027,106914,76392,90077,58783,67512,109609,92553,80727,69120,40254,91356,57182,48893,38027,22679,154196,187123,171982,179156,162877,159428,171012,149555,159290,133234,126333,172075,161556,151821,143094,108889,160951,131351,118768,106655,82596,157006,167795,146858,152951,130937,133559,143107,110863,128837,93266,100016,143794,130972,119803,104989,73882,126028,93358,81814,68425,45348,158411,167525,147271,150717,130735,134994,142420,108286,129294,93932,103403,143601,128847,120511,103904,76210,123328,92932,80881,69888,43430,146872,135714,114098,112193,92644,104752,105605,68934,93598,57336,78160,107118,87120,86029,63564,48777,80639,57318,49048,37305,18362,167265,165754,148676,146167,130097,136136,143741,108113,129657,93736,106264,143625,124282,122906,100242,80437,119296,93071,81905,68362,40008,154481,132682,116611,106358,93642,108328,106026,71569,87694,57524,82419,106816,81740,87116,62536,53335,76650,56530,48531,37123,16949,157823,130945,117680,107834,91601,110584,104401,72578,85760,56712,84512,106228,80384,89103,60400,55373,73873,56857,48437,36930,16435,129242,94723,82758,69602,52096,79619,65085,42502,47021,28743,61181,69426,42780,55179,29980,33750,39021,28724,24327,16300,8228,194253,183636,175627,171153,159803,167529,169280,145374,154560,131897,140327,171065,151158,158009,134299,121943,145572,129866,117764,107289,71792,183216,162877,151336,143562,123567,146469,137933,112317,118645,93183,117309,142538,112663,128355,94043,91462,106007,93993,83404,67423,45247,182268,163033,151351,143303,120695,148693,138013,112920,116074,92651,119634,143099,109448,129027,92662,94418,107741,91195,84258,65330,49287,158905,131106,117991,106012,80193,121459,98203,77949,73577,56621,94911,106165,68533,93103,57986,63823,69805,51395,52207,33602,36881,180553,162266,151288,143470,116915,153100,134461,115589,110611,92531,123871,141786,108089,130734,94002,96025,106846,86257,86149,63165,56666,154665,131638,118095,106929,74268,125662,95367,79966,69337,56175,99405,106854,71148,89494,56592,66701,69104,47176,53176,32009,45775,153593,131182,117830,106249,72569,127214,93904,80667,69230,56536,102114,105619,71821,87014,57056,66994,68657,45373,54490,31341,46553,115199,92321,81954,68341,37811,91809,56734,50084,38175,26028,76013,65441,42236,47906,28959,40801,37673,20030,28151,12532,50550,175903,162463,150504,142392,106147,162731,131996,118930,107334,87322,135877,140482,110345,121312,92748,101013,107033,76504,90013,58826,72816,146719,130525,116982,106495,71000,130134,93968,81883,69497,48946,111783,100943,74601,80425,56951,70172,68622,40161,55837,29257,64215,144135,130027,119284,106573,72352,127970,93499,82311,68705,46978,114382,100045,76829,77358,56663,70685,68844,38788,56022,28861,60032,107663,92659,83831,66520,43714,86782,56901,48795,37060,20900,84902,60920,46199,40676,28895,43475,36810,16664,28664,12481,66526,143592,129031,120496,103869,76168,123385,92987,80994,69685,43625,120677,97230,78082,73108,56409,72366,67927,37560,56992,29347,67276,107089,87260,86029,63474,48867,80753,57155,49153,37284,18433,88496,58833,47563,37970,28687,43746,38124,18596,26225,12044,65639,107565,84612,86821,62247,50480,79857,56762,48857,36990,17755,90372,57321,48137,36980,29226,46534,36018,19268,24452,12205,54095,68908,46247,53148,32434,30743,42220,28794,24433,16463,5901,56019,28763,24928,17405,10547,25215,14637,8253,8489,3922,93728,196064,192372,191264,186351,173509,191347,183293,175294,170668,144590,191344,183612,175681,171268,161353,165866,170130,144886,157520,130735,141378,188068,178492,179095,166327,150263,175438,161853,150687,142014,107106,183620,163042,151592,143407,126373,144236,139810,110792,119532,94157,126280,188011,177363,179314,165680,151702,173515,161588,150183,143581,108428,183216,162911,151315,143570,123636,146519,138009,112101,118840,93148,125744,170841,149233,159325,132591,123835,142356,131989,119438,105831,73653,160029,131756,118473,106852,81159,118772,100079,76899,76364,56430,123049,187993,174042,181440,162427,155345,171323,162224,152332,141467,111115,181817,162688,151092,142378,119896,150972,136526,113971,113041,92973,132220,170709,143723,161375,132143,127596,143671,127754,121148,103288,78558,157014,130503,118481,107244,77133,123385,96236,79524,71531,56372,126943,169841,143879,162717,131730,128154,143159,125851,122303,101545,81530,154652,131665,118152,107012,74374,125500,95473,79846,69499,56198,118600,143477,108158,128820,93162,97531,107104,83345,87003,61717,57784,118099,93183,81407,68383,39450,90914,57131,48136,37862,28492,137543,187972,171413,182244,163010,157236,171125,155225,156040,137753,118604,177534,162036,151205,142889,109035,159530,130260,119401,107658,90733,144934,170056,144805,158464,131217,130296,142845,119247,125393,98113,90394,149303,130881,117403,105885,68353,131332,94324,82472,69461,50909,144110,169811,145029,156375,130316,132408,143393,116453,126589,96131,93819,146985,130490,116996,106299,70950,130142,94156,81954,69265,49212,134333,139080,111108,119757,93470,101615,106606,73767,91342,57718,70118,107341,92337,83249,68292,41976,88871,56999,49229,37299,21736,151792,167753,146824,153021,131295,133439,142848,111388,128571,93427,99995,143345,131155,119712,105186,73682,126338,93394,81744,68586,45272,142444,137333,113543,114561,92749,103884,106032,69865,91930,57436,75800,107364,90214,84510,65441,46493,83653,56606,48366,38039,19655,145705,135910,113851,112678,92666,104548,105781,68392,93853,57608,77776,107194,87246,85994,63677,48664,80948,57100,49124,37243,18568,122509,96221,79665,70427,56273,72469,69592,39491,54156,29115,55173,69888,48435,52975,32184,28270,44943,28960,24576,16374,6210,180433,184864,174132,171696,161977,164274,170973,144133,160677,131505,135091,171056,156726,154781,138172,116315,152823,130896,117284,107026,71293,176716,163190,149880,143824,130663,140399,141986,108999,125731,93071,110671,142853,119666,125434,98505,84871,113743,93154,81331,68193,37375,180237,162954,151758,143628,128629,141759,141383,110015,122923,92882,112306,143583,117847,126358,96768,86882,111843,92364,81204,67857,38548,162973,131701,118943,107013,87014,114596,101797,74426,80308,57529,88889,106831,75249,90168,58728,59097,70013,56222,48810,37629,22193,183259,162877,151315,143583,123713,146519,138149,111890,119016,93058,117189,142763,112734,128270,94183,91266,106006,93994,83369,67549,44690,160030,131897,118473,106817,81355,118498,100122,77039,76433,56438,92937,106606,70624,91936,56428,62777,70134,54428,51114,34460,31278,159124,131092,118081,105956,80460,121263,98274,77878,73717,56706,94853,106103,68739,92666,58022,63976,69762,51669,52039,33742,33929,122509,92651,81981,69426,42578,88290,58914,47433,38717,28740,67912,67727,39456,55612,29319,38912,37355,23638,27081,13657,33843,179064,163033,151345,143288,114240,155082,134144,115589,108398,92167,126299,143521,108124,128854,93394,97335,107118,83512,86982,61619,60791,153858,131126,117991,106012,72933,127213,93974,80596,68769,56942,101882,105726,71736,87175,57147,66722,68922,45517,54241,31558,49735,151734,130518,118242,106264,70343,128733,92342,83313,69903,53833,105216,103687,73347,84536,56837,67577,68711,44684,54578,30669,49949,112880,92882,81001,68187,36972,93533,57860,49390,37769,24352,78522,64286,42874,46169,28688,42265,37453,18792,28311,12350,52740,147197,130419,117045,106068,70929,130359,94087,82009,69265,49283,111321,101279,74628,80363,57056,69997,68677,40326,55855,29302,57253,107495,92065,83347,68453,41710,89137,56893,49215,37447,21752,82278,62136,45219,42879,28960,42802,37246,17189,28632,11964,53683,107215,93037,83599,66766,43649,86924,56951,48773,37123,20844,84805,61066,45968,40959,28843,43370,36968,16665,28663,12400,45769,69532,53469,51331,34330,25409,47659,28832,24374,16972,6957,53972,30336,23328,17730,11933,22464,16310,5911,12040,3989,75650,188068,182268,176629,169642,145914,180004,162293,151591,143155,116116,170803,165649,148697,146447,130251,136311,143027,108092,129993,93786,111314,171199,158949,154088,138787,113958,154776,131343,118257,106480,73627,154558,133101,116541,106759,93080,108062,106062,71786,88233,57215,98497,171049,156859,154851,138011,116307,152867,130951,117396,106929,71454,157612,131366,116907,107954,92253,109982,104835,72081,86292,56762,96153,142839,119721,125393,98476,84921,113938,92959,81492,68172,37430,129044,94233,82843,69637,52586,79023,65603,42412,47225,28794,98704,171302,153614,157301,135539,119336,148697,130392,117605,105571,69241,163010,131667,119075,107048,86994,114561,101887,74265,80583,57465,102551,143212,115275,126541,96369,89108,108944,92308,80968,69587,41228,129635,93555,81883,69497,47990,83269,62065,44423,44361,28873,99899,142818,112734,128320,94204,91090,106260,93880,83208,67710,43972,126716,94157,81974,68839,46028,84342,62242,45506,42065,28751,87281,106656,70828,91893,56471,62538,70133,54534,51226,34474,27743,85530,56768,48598,36904,20944,53654,30790,23318,17785,11997,115683,170639,144192,160827,132207,127610,143630,128083,120854,103511,78346,157276,130629,118125,107278,77434,123280,96467,79188,71882,56364,114973,141852,107651,131091,93981,95935,106628,86902,86205,63193,53691,119581,93792,81933,68964,40719,89658,58266,47564,37751,28676,113601,143529,108108,129129,93323,97174,107244,83568,86941,61754,57397,118434,93184,81492,68102,39851,90884,57153,48157,37392,28814,98306,105781,71660,87266,57202,66624,69056,45561,54127,31656,39399,75936,56415,48799,37011,16731,56087,28697,25705,17119,10122,122027,141112,109964,124534,93183,98862,106187,79893,89263,60190,63325,113041,92932,80902,68335,36988,93327,57951,49300,37873,24453,106044,102993,73788,82007,56295,69541,69174,42263,55142,29881,44928,71223,56399,48208,37271,19129,55059,29403,24614,16840,8497,108707,101545,74607,80264,57161,69886,68705,40468,55811,29337,47067,69168,56152,50293,36760,21200,52286,28991,24882,16576,7939,81787,61989,45184,43084,28951,42795,37224,17226,28610,11987,29536,38170,28191,25981,14978,10797,23962,11999,10176,5756,2093,155691,167802,147031,151370,130307,135015,142728,108805,129216,93044,103224,143711,129461,120336,103813,75943,123651,93288,81205,69173,44145,145835,136015,114152,112699,92672,104486,105822,68054,94135,57644,77440,107299,87336,85974,64000,48376,81222,56826,49264,37258,18732,149345,134573,115546,109609,92512,104990,106740,70805,91321,57217,79434,107357,85123,86652,62521,49680,80503,56916,48752,37116,17785,125128,94730,80442,68653,56827,75395,67976,40521,51633,29231,57636,68733,46760,53184,32326,30483,42542,28817,24344,16575,5912,157009,131527,116631,107998,92464,109778,104969,71913,86453,56894,84176,106390,80313,88997,60633,55155,74457,56693,48529,36909,16548,128994,93989,82955,69566,52783,79023,65568,42341,47365,28796,60133,69846,43408,54978,30181,33227,39491,28742,24373,16300,6948,131602,93898,82667,69119,50550,81508,63529,43168,45482,29341,62836,68818,41381,55159,29952,34679,37884,28686,24418,16950,11246,90748,57132,48920,37734,22449,51472,32025,22106,20206,11944,40332,36969,17739,28596,12021,18032,16366,12197,10846,5141,13534,160345,131757,118544,106831,81684,117925,100492,76989,76630,56508,92489,106627,71082,91884,56472,62271,70169,54610,51331,34531,29623,125451,93058,81631,68328,45397,86667,60435,46207,40240,28952,67025,68221,37216,56341,30006,38085,38020,24860,26681,14242,25666,122692,92686,81785,69426,42739,88389,58963,47145,39015,28730,67792,67856,38956,55983,29347,38836,37215,23954,27073,13658,25687,80223,57412,48865,37383,18088,55134,29621,24051,16664,11920,43132,37398,18511,25894,11998,20673,16739,8004,11454,4379,31327,118588,93218,81492,68096,39971,90847,57168,48157,37139,29088,72687,67458,40626,50697,29165,40228,37411,21010,27815,13122,32194,76223,56417,48727,37082,16739,56044,28741,25640,17090,10215,47460,34163,20787,22538,11987,21121,16551,7380,11763,4093,32972,73556,56642,48294,36959,16377,57056,29691,24852,16930,9224,49053,33560,21004,21393,11924,21839,16585,6628,11828,4004,25213,38547,28731,24319,16545,7970,27258,12199,10187,5942,2361,26361,13649,8745,7620,3934,9410,5772,1649,3910,973,58328,199314,198322,196497,196087,188083,198442,194190,189899,188057,181091,186984,195556,188536,192245,183462,179143,187812,175525,180598,163927,155563,196022,194255,189901,187969,171460,193790,183625,175424,171041,154993,179359,186571,172755,177468,161826,161122,170885,145788,160550,130431,134328,196089,194164,189975,187641,171792,193523,183503,175274,170796,154353,180705,186246,172970,175924,162442,161264,170568,142749,162790,132002,134286,188068,182269,176680,169748,145756,180323,161984,151591,143429,116312,170411,165663,148642,146656,130546,136205,142620,108072,130127,93918,113760,196078,193712,190274,187132,172409,192388,183582,175453,171032,149547,185801,185127,173879,172236,161402,164254,171131,143995,160985,131351,137187,188024,180880,177288,167781,148273,178256,162686,150771,143016,111073,176875,163449,149721,143582,131064,140019,142260,108681,126210,93359,118851,187993,179065,178631,167618,148938,177001,162233,151107,142356,108524,180089,162459,151803,143593,128974,141765,141230,109966,123370,92967,119140,171151,153922,157106,135734,119020,149048,130524,117543,105676,68711,163030,131903,118993,107089,87225,114274,101908,74566,80731,57156,114290,196076,191828,191598,185471,174582,189950,182931,174342,171137,143904,194174,183626,175417,171302,158619,168564,168560,145633,154518,131224,145053,187950,176008,180493,164270,153108,171458,162195,151864,142868,109209,182611,162909,151478,143212,121710,147555,138333,112982,116635,92896,132103,188039,174635,181117,162960,154495,171324,162476,152276,141874,110511,182022,162562,151351,142818,119652,150650,136792,113712,113609,93246,131372,170709,144549,160410,132246,127555,143621,128454,120491,103729,78163,157499,130700,117810,107376,77708,123167,96727,78872,72204,56336,131407,187608,170887,183613,163049,156466,171190,159859,153675,139788,113948,179047,163196,151437,143183,114877,154383,134417,115812,108679,92202,137783,171258,143905,161882,131428,128600,143549,123651,123066,99899,84351,154226,131056,118082,106102,73346,126941,94134,80562,68068,57587,133845,170918,144143,160028,131715,129574,143253,120843,124005,100038,86818,152256,130609,117885,106551,70574,128501,92662,82566,70064,54253,125280,141446,109679,124869,93184,98791,105866,80410,89208,60225,63129,113041,92932,81211,68292,37041,92938,58001,49257,38168,24540,149511,195984,188172,193244,183211,178504,188067,178211,179179,165857,151752,190545,183057,174902,169863,143881,183547,163050,151577,143165,125851,165502,187298,171920,179101,163031,159234,171163,150563,158521,134018,125154,172932,161426,151093,143455,108476,161518,131148,118887,107139,83295,162701,186421,172699,178705,162645,159808,170643,148724,159550,132275,128140,170775,163018,151822,142714,109427,159915,131624,118151,106712,80590,159991,167902,146940,151656,130266,134931,142868,109000,129182,92596,103236,143735,129642,120350,103743,75769,124105,93310,81246,68935,44432,169194,186290,172970,175890,162547,161172,170611,142987,162503,132051,132321,171258,160205,153590,140559,112170,156375,130322,118984,106978,76630,167549,165614,148620,146944,130475,136184,142425,108071,130141,94115,105804,143335,125374,122262,100963,79612,119757,93435,81793,68642,40169,171020,164971,149133,144247,129838,138980,143215,108392,128174,93323,108150,143315,122607,123186,99990,82378,117216,93232,81211,68740,38915,156632,131723,116862,107466,92730,109582,105165,71666,86938,56916,83825,106571,80188,88977,60982,54846,74746,56615,48599,36847,16664,189703,183161,175692,171258,161783,165638,170064,144849,157956,130937,137751,171025,153978,157085,135895,118815,149253,130574,117444,105781,68450,183663,163175,151638,143513,126604,143906,140020,110792,120584,93350,114711,143142,115856,126680,96236,88836,109343,92371,80641,69633,40868,183323,163025,151114,143741,124604,145671,138737,111126,119479,93373,116748,142903,113006,128159,94359,91090,106590,93284,83249,67760,44098,160621,131561,118684,106746,82063,117791,100423,76864,76930,56571,91978,106985,71272,91770,56594,61687,70169,55185,51183,34636,30440,182039,162644,151367,142818,119686,150524,136828,113816,113743,93154,121174,142476,107803,129231,94513,95087,107475,89333,84467,65477,51379,157542,130840,117627,107356,78002,123061,96727,78782,72393,56258,96233,105536,69521,93276,57308,64810,69048,50487,52562,32820,39430,154839,131723,118579,106816,75207,124415,96187,79776,70013,56216,97574,107338,70951,90517,56936,65769,69426,47744,53183,31975,41108,118981,93093,81575,68334,39972,90734,57273,48114,36840,29424,72399,67529,40555,50837,29250,40269,37383,21091,27678,13241,43887,197803,194137,189668,188001,174043,191126,183603,174861,171324,162239,171537,187798,171533,181882,162645,157722,170694,154764,156755,136652,120710,191006,183529,175182,170709,143926,181530,163250,151719,143658,127872,155964,170019,144823,157177,130559,131450,143576,117096,126317,96446,96323,190596,183044,174929,169918,143761,183557,163076,151564,143144,126069,158566,169196,145430,154588,131693,132522,143288,114205,127472,95549,98847,173136,161462,150852,143514,108418,161534,131336,118797,107068,83527,140730,137407,112941,118245,93149,102293,106012,72891,91427,57138,84683,187812,183634,175736,170884,144343,182259,163018,151128,143337,120261,164731,167945,146905,151727,130468,134743,142839,109211,129182,92321,107635,171313,162072,152430,141140,111094,158583,131162,117830,106411,79739,147233,136471,113956,112860,92861,104136,106032,68368,93576,57860,90347,171258,160409,153422,140602,112106,156529,130154,119097,107068,76630,150645,134453,115456,110240,92602,104885,106130,70700,91664,57595,88710,143313,125487,122156,101229,79417,119757,93575,81688,68677,40304,125139,95011,80182,69021,56263,75325,68418,40149,52153,29083,90787,188057,181006,177218,167718,148248,178364,162807,150826,142841,111500,176391,163681,149791,143238,131302,139781,142373,108784,126318,93449,115947,171032,154554,156725,137444,117295,151215,130433,118067,106208,69901,159467,130943,119273,107405,90376,111466,103778,73432,83743,56656,105457,170947,154140,156938,135993,118905,149163,130664,117494,105752,68224,163159,131968,118887,107265,87301,114016,102356,74356,81019,57029,101928,143099,116131,126659,96137,88780,109483,92364,80726,69430,40645,129987,93771,81646,69749,48574,82861,62401,43539,45161,28952,107273,171003,149513,159213,133039,123359,143575,130609,119333,106069,73214,160816,131366,118789,106711,82209,117826,100312,76828,77092,56571,107896,143288,110667,128852,93161,92354,107947,92197,84083,66212,46313,125817,93212,81855,68391,45341,86442,60506,46262,40513,28919,106587,142476,107893,129336,94283,95058,107462,89535,84356,65624,49691,123070,92896,81197,69608,43295,88119,59181,46816,39379,28697,91485,105571,69277,93409,57273,64900,69084,50501,52589,32827,32850,80520,57487,48893,37404,18241,54756,29962,24076,16676,11921,129068,188077,171338,183268,162961,156602,171259,158301,154494,138275,116133,179012,162568,151345,142783,112754,156869,132632,116506,106203,93902,140715,170971,144100,160028,131989,129448,143183,121312,123495,100240,86656,152453,130700,117724,106641,70786,128500,92775,82062,70098,54554,137748,170420,144442,159231,131056,130184,142679,119812,125449,98379,89379,149541,131336,117704,105983,68901,129692,94535,82723,69707,51787,128892,141050,110021,122566,92672,100060,107299,77393,89929,58914,66121,111179,92503,80931,67764,39522,92694,57434,49174,37214,23835,145080,169176,145457,154588,131659,132627,143253,114351,127346,95689,95625,145446,129831,118106,107184,71551,129072,93358,82367,69245,47463,137061,137667,112668,118399,93204,102203,105906,73158,91405,57153,71839,106204,93676,83509,67368,43096,87301,57182,48584,37447,20972,139577,137929,113018,115688,92638,103609,106390,70358,91872,56295,75371,107713,91000,84328,65301,45990,84654,56824,48479,37335,20396,118588,98098,77928,73577,56571,71839,68341,36981,57143,29705,52881,69532,51275,52397,33413,26530,46288,28696,25056,16598,6583,165094,165593,148710,147308,130413,136170,142032,108055,130522,94072,105546,143306,125641,122003,101488,79346,119596,93736,81653,68663,40468,152845,133662,116058,107641,92037,107816,106811,71163,89227,56803,81725,106978,83065,87031,62004,52459,77827,56859,48436,37218,17225,155985,132177,116807,106997,93199,109155,105270,71967,86959,56922,83588,106621,80145,89130,61137,54510,75131,56462,48655,36967,16667,128809,93079,83073,69693,53490,78813,65462,42286,47744,28875,60067,69223,44088,54830,30351,32778,39971,28743,24372,16311,5733,163134,131995,118888,107314,87301,114043,102469,74236,81181,56882,88265,106838,76349,90105,58783,58572,70609,56324,48189,37838,20654,130071,93757,81848,69637,48701,82769,62506,43239,45461,28961,64084,68601,40141,55759,29248,35427,37070,29115,25680,15544,15466,127795,93575,82206,68783,46703,83884,62368,45365,42501,28823,65083,68964,38653,56058,28817,35802,38958,27392,26157,14802,17814,86390,56895,48844,36982,20935,53381,30916,23347,17977,11986,41484,36894,16541,28664,12597,19561,16921,9620,11103,4808,23703,198270,194190,189604,188079,178733,186771,186070,172982,175548,162266,166849,187670,170733,183633,163095,156456,171204,159958,153681,139831,113975,192746,183316,175615,171050,151700,175039,165739,148712,146096,130077,148611,171304,143887,162030,131616,128257,143584,124225,122961,100159,85398,192369,183457,175531,170891,149338,177384,164263,149566,143023,131316,151635,170964,144099,160303,131757,129448,143219,121458,123278,100471,87957,178046,162463,150589,143106,110114,158976,130924,117764,107833,91476,131164,141784,109223,125416,93093,98651,106243,80369,89103,60435,69248,191168,183427,175280,170675,144282,181049,163295,151743,143615,128257,155555,170037,144933,157387,130609,131113,143577,117222,126618,96551,94907,175340,161909,150420,141993,107445,162863,131757,118789,106768,86923,137187,139655,110848,119575,93968,101264,106887,74829,90567,58377,77963,173362,161517,150452,143564,108358,161832,131358,118538,107327,83688,140303,137933,112415,118532,93233,102168,105885,73339,91371,57167,79034,142479,131810,119494,105831,73165,126583,93807,81722,68985,45647,116106,99926,76877,76161,56416,71554,68537,38006,56099,28719,76994,188079,183325,175923,170095,145187,181772,162646,151072,142485,119593,167044,167188,147417,149484,130966,135135,142657,106688,130626,94443,108473,171304,160718,153087,140846,111854,156732,130468,118727,107089,77036,150218,134348,115687,110541,92503,104956,105620,70726,92142,57489,93363,171068,159509,153779,139474,113543,154659,131588,118151,106873,74204,153575,133864,115897,107838,92081,107533,106854,71142,89409,56627,92119,143429,122908,123227,99633,82188,117847,93274,81254,68571,39240,126792,93925,80652,69315,56480,76586,67052,40731,50537,29010,92608,171041,154952,156376,137599,117111,151509,130175,118425,106249,70028,159340,130473,119273,107679,90572,111179,103834,73326,83982,56894,97981,142956,119031,125603,97741,85908,112754,92756,81057,68082,36854,131692,94234,82521,69391,50802,81095,64069,43000,45922,29026,94445,143407,116292,126498,96277,88479,109665,92645,80733,69030,40436,130105,93898,81918,69517,48863,82622,62632,43281,45419,28995,83991,106551,73682,91266,57640,60156,68761,56719,50154,36410,23518,88555,57174,49174,37123,21734,51752,32240,22796,19021,11944,113104,187894,175140,180775,163428,153998,171172,162783,152036,142219,110088,182171,162841,151220,143015,119616,150272,137177,113719,114260,92924,130784,170562,145389,160565,131250,127555,143593,128917,120546,103884,77539,157872,130916,117381,107525,78492,122537,97209,78159,72989,56409,125258,170450,142630,163029,131897,127951,143442,126570,121996,101908,80536,155442,131142,118767,106726,75718,124282,96277,79615,70337,56258,116204,143629,108100,129796,93681,96166,107503,84571,86862,62184,55628,119382,93162,81855,68391,40042,90601,57336,48094,36979,29290,129115,170971,144090,160508,131667,129343,143253,121669,123087,100592,86279,152634,130881,117452,106768,71159,128323,92908,81529,70196,54828,124564,141889,109131,125543,93043,98791,106229,80348,89103,60471,62323,113546,93253,81246,68257,37253,91872,58448,49636,37936,25001,125842,141185,110106,122782,92735,99633,107370,77652,90033,59027,65617,111535,92482,81016,67848,38919,93079,57378,49229,37314,23955,108424,101811,74446,80103,57588,69760,68803,41016,55452,29642,46314,69929,56199,49149,37488,20242,53469,28967,24870,16726,8025,149116,168063,146234,154204,131056,133202,142664,112664,128319,94093,98686,142385,131945,119453,105802,73144,126654,93736,81954,68964,45702,140340,138047,112983,116131,92651,103273,106551,70539,91818,56418,74785,107784,91195,84293,65435,45750,85033,56796,48542,36972,20776,143751,136547,113935,113021,92967,104135,106159,68561,93005,57986,76522,107629,88283,85398,64728,47326,82329,56416,49387,37537,18957,121440,96138,79552,71510,56372,72445,67930,39527,55339,29368,54793,68993,49800,52625,32679,27628,45377,29115,24428,16584,6266,151839,133998,115777,108006,92166,107225,106993,71016,89606,56663,81584,107118,83260,86997,61808,52410,78177,56831,48479,37119,17361,126642,93938,80618,69119,56662,76362,67311,40731,50466,29115,58603,68663,45473,54439,31369,31577,41242,28695,24592,16366,5825,128684,92617,83234,69798,53750,78644,65386,42201,48047,28951,59990,68935,44417,54627,30577,32748,39993,28773,24363,16312,5743,93837,57685,49475,37754,24153,50245,33244,21158,21186,12050,39003,37440,18763,28302,12352,17595,16834,11932,10100,5961,6294,194177,183680,175572,171113,159280,167946,168829,145618,154708,131378,140921,171039,149596,159389,133430,122771,144227,129873,119368,106573,72707,182912,162663,151599,143294,122566,147289,137786,112913,117201,93212,118155,142910,111270,128627,93427,92057,107516,92730,83816,66605,46925,182215,162877,151191,143064,119581,150271,137318,113558,114470,92840,120741,142538,108539,129272,93590,95023,107392,90116,84495,65491,50518,157934,130952,117542,107343,78653,122417,97315,77935,73283,56416,95766,105802,68491,93739,57623,64705,69160,50726,52484,32918,39277,179926,162363,151564,143141,115800,153920,134629,115616,109308,92371,124369,143363,108079,129901,93736,95999,107635,84725,86723,62345,58331,154527,131378,118327,106305,73606,126514,94302,80639,68441,57130,100614,106083,71631,88003,57404,66652,68803,46386,53150,32404,47686,152775,130881,117346,106929,71265,128182,93048,81256,70176,55122,103920,104527,72402,86062,56592,67633,68356,45320,54613,30831,48294,113708,93169,81295,68228,37332,91872,58244,49726,37986,25056,76761,65442,42453,47133,28760,41340,37769,19347,28301,12373,52834,175488,161804,150826,142014,106965,162965,131702,118886,107033,86959,136851,139760,110786,119694,94051,101229,106816,75166,90266,58637,74636,145768,129986,117328,107338,71499,129502,93429,82100,69406,47764,113197,99983,75876,79270,56732,70397,68335,39978,55858,29081,66037,142532,131834,119432,105907,72997,126681,93968,81883,68964,45817,115545,100107,76989,76392,56444,71344,68622,38124,56101,28743,62091,107826,91356,84132,65701,45520,85179,56831,48578,36817,20952,85990,60274,46298,40147,28832,43533,36952,16387,29050,12442,68508,143658,127837,121078,103358,76736,122389,92651,82093,69350,42542,121731,96384,79446,71581,56406,72439,67698,39555,55536,29304,68530,106726,86516,86261,63214,49344,80293,57237,48676,37411,18006,89461,58132,47683,37587,28676,45407,37110,18868,25401,11968,67799,107089,83471,86997,61576,52481,78366,56753,48557,37055,17432,90784,57132,48143,37707,28618,46907,35724,19513,23998,12044,54871,68852,45488,54305,31502,31409,41402,28705,24583,16374,5826,56096,28750,25764,17069,10050,25424,14523,8367,8214,3924,92556,170710,154482,156782,136471,118563,149379,130861,117388,105997,68362,162238,132100,118853,107362,87694,113777,102811,73929,81740,56364,101557,143414,116488,126624,96116,88213,110240,92602,80733,68694,40196,130261,94142,81954,69300,49248,82313,62844,43372,45397,29003,97976,143133,113372,128165,94996,90292,107424,92183,83285,68418,42689,128335,93253,82317,69028,47021,83721,62199,45254,42780,28961,86174,106460,72113,91497,56876,61034,69826,56018,50763,35176,25858,86888,56972,48773,37095,20872,53220,31185,23239,18095,11976,103563,142735,108608,129223,93394,95023,107349,90391,84474,65392,49097,123567,93015,81204,69447,43836,87669,59594,46278,39970,28743,91058,105731,68287,93993,57594,64579,69300,50712,52463,33033,32518,80984,57044,49159,37173,18674,54755,29909,24076,16740,11921,90526,107103,70763,91195,57182,64949,69784,48532,52976,32190,34560,80193,56867,48844,37018,17776,55586,29154,24297,16377,12142,70055,67731,40640,51395,29279,40228,37299,21393,27310,13571,23421,42452,28802,24320,16584,5903,28639,11944,10349,6275,3209,119517,142084,108893,125817,93162,98722,106319,80334,89047,60526,62170,113882,93050,81407,68187,37409,91873,58130,49636,38076,25170,103827,104024,73502,83148,56564,67969,69588,43274,55097,30053,43523,72569,56295,48400,36758,17844,56536,29235,24923,16577,9003,107441,101887,74321,80463,57494,69634,68929,41164,55143,29961,46156,70034,56252,48654,37727,20269,53624,28996,24813,16760,8084,81128,62030,44499,44278,28901,42704,36960,17740,28588,12020,29338,36883,29400,25771,15389,10448,24145,12174,10178,5800,2115,113311,100184,77074,76504,56430,71266,68622,38209,56130,28744,50259,70119,54513,51176,34461,24495,48946,28907,24456,16328,7629,85639,60345,46263,40161,28896,43526,36937,16410,29006,12371,32788,38076,24681,26789,14158,12763,21735,11932,10331,5863,1742,87595,58920,47364,38788,28732,43744,36705,18405,27609,12178,34285,37264,23779,27080,13657,13678,20900,12073,10155,5809,1650,55151,29516,24033,16664,11920,23492,16277,7361,9739,3924,19422,16621,7994,11463,4369,6638,6904,3923,3353,1541,296,186176,194853,189153,187803,183634,181969,187978,171404,182268,163031,159661,188057,179856,177838,167975,148521,177649,162231,151024,142944,109267,188663,183141,175484,171314,162144,165293,170048,144848,158675,131147,137149,170646,154525,156853,136526,118416,149491,130896,117283,106208,68405,192926,183700,175627,171280,160550,166710,169882,144960,156619,130251,139742,171211,152691,157609,134447,120977,147252,130454,117081,105914,70984,183465,163106,151450,143300,125626,144762,139445,110988,119637,93695,115733,143099,113672,128025,95052,90166,107621,92015,83271,68508,42928,194088,183425,175663,171177,157520,169482,167646,146816,153338,131232,142308,170763,148464,159388,132115,124590,143090,131395,119517,105276,74866,182215,162877,151261,143099,119532,150264,137515,113368,114912,92573,120621,142763,108720,129210,93142,95016,107544,90391,84474,65442,50558,181267,162785,150791,143077,118840,151574,136015,114076,112684,92686,122540,142356,105802,131989,94198,95493,107314,87316,85924,63985,54046,155968,130721,118810,106788,76364,124042,96187,79594,70624,56302,96754,106859,70790,91280,57237,65020,69678,48666,52954,32220,44078,192424,183580,175418,171039,149534,177075,164754,149349,143723,130440,151440,171058,144058,160907,131366,129365,143141,122235,123242,100242,87350,178233,162560,150672,143177,110808,158310,131492,116730,107984,92379,130163,142197,108788,125851,93394,98616,106305,80363,89012,60554,67876,176881,162289,151057,142455,108111,160103,131546,119224,107398,89689,133056,141286,109959,123216,92897,98912,107593,78275,89761,59300,69833,148731,130518,117599,105521,69134,131594,93792,82717,69104,50509,109935,101887,74391,80597,57395,69640,68853,41325,55151,29953,64007,173774,161749,149708,143711,108273,162030,131575,118271,107356,84374,139855,138290,111644,119247,92932,102349,106264,73367,91371,57301,78116,143008,131351,119404,106012,72835,126892,94059,82009,68874,46056,114948,100429,76969,76615,56487,71098,68677,38324,56121,28753,69525,143801,130142,120384,104346,74765,125416,93093,81533,68335,45412,118651,98420,77823,73767,56887,71929,68215,37209,56439,29921,64930,107503,88871,84936,65050,47081,82827,56444,49036,37734,19105,87724,58950,47202,38957,28731,43702,36749,18255,27721,12200,79584,188031,182194,176675,169253,146303,179057,163123,151387,143247,114561,172138,165539,148824,145487,129881,137364,143557,108079,129235,93394,112606,171256,157956,154467,137876,115540,153978,131197,118046,105843,73340,155952,132366,116736,106057,93853,108825,105816,71695,87246,57237,100031,171099,155722,155501,137970,116689,152093,130539,118026,106480,70427,158675,130504,118920,107686,91153,110822,103603,73502,84801,56753,97393,142507,119536,125679,98113,85459,112986,92967,80973,68320,37003,130661,94408,82401,69693,51324,80573,64546,42684,46407,28705,101171,171205,152823,157568,134370,121004,147484,130293,117242,105661,70956,162591,131813,118593,106950,86118,115129,101509,74587,80299,57146,103771,143294,113743,127864,95241,89941,107803,92074,83030,68634,42325,128629,92995,82675,69069,47148,83699,61933,45093,43260,28951,101434,142735,111843,128257,93931,91882,106870,93291,83418,66996,45336,126423,93555,81673,68712,45267,85979,61248,45897,41094,28773,88651,106264,70013,91908,56882,63662,69846,53574,51247,34401,29112,83925,56895,48415,37701,20002,54024,30421,23371,17731,11933,117603,170582,142630,162888,132023,127720,143570,126667,122038,102545,79640,156163,130553,118796,106985,76433,123903,96242,79594,70624,56416,116018,142670,108085,130105,93842,96221,107266,85298,86548,62597,54679,119827,93449,81744,68551,40197,90320,57633,48063,37107,29043,115642,143123,108503,127887,93540,97651,106628,82721,87108,62214,58597,117111,92973,81205,68900,38717,91353,56707,48143,38895,27511,100044,105004,71835,86628,56867,67414,68461,45313,54480,31009,40977,74534,56666,48563,36860,16599,56119,29746,25308,16915,9654,124085,141251,109930,123350,92952,98799,107581,78436,89691,59398,64523,112306,92638,81147,67899,37753,93642,57412,49537,37503,24026,107660,101923,74481,80703,57254,69690,68803,41452,55173,29952,45847,70343,56252,48135,38175,20011,53833,29108,24638,16824,8214,110551,100313,75267,79780,56684,70544,68412,40021,55857,29110,47842,68375,57286,50350,36018,21978,51148,29394,24614,16553,7707,82042,62649,45435,42149,28796,43054,37166,16950,28663,11933,30516,38573,26885,26343,14615,11719,23033,11986,10133,5744,2104,165735,186350,172912,176425,162625,161052,170696,144464,160446,132301,132061,171259,161326,152524,141143,111660,157458,130650,117907,107349,77610,165952,166299,147920,148367,130258,136059,141943,107271,131324,93876,105105,143337,126338,122052,101761,78717,119504,94115,81939,68853,40959,168597,165539,148929,145627,129852,137139,143573,108126,129376,93394,107013,143556,123608,123011,99893,81396,118736,93113,81582,68146,39963,155219,132506,116646,105908,94057,108714,105802,71750,87281,57217,82866,106907,81019,88055,61906,53446,76343,56423,48686,37116,16748,177764,162386,151093,143784,129993,140897,141363,109734,124834,93184,111055,142429,119775,125589,98168,85369,113041,92967,81113,68299,37034,161333,132143,118789,107679,88233,113041,103253,73592,82266,56416,87576,107194,77092,89965,58665,58158,71454,56371,48236,36970,19720,162667,131772,118705,106831,86292,115129,101545,74516,80349,57167,89232,107026,74296,90904,58111,59539,69378,56198,50037,36893,23159,128734,93071,82654,69119,47225,83642,61808,45254,43295,28950,64903,68439,39379,55874,29027,35719,37932,28401,25806,15198,19404,182216,163024,151156,143099,120107,149689,137655,113277,115275,92364,120594,142818,108944,129238,92658,95058,107629,90692,84384,65371,49808,158343,131232,117759,106635,79466,121647,97938,78075,73381,56508,95352,105837,68295,93879,57644,64383,69426,50788,52618,33244,37345,156339,130358,118928,107013,76545,123847,96166,79559,70828,56408,96704,106410,70728,91461,57462,65047,69406,49037,52849,32338,39080,119777,93429,81799,68622,40126,90391,57676,47970,37201,28963,71028,68292,40345,51844,29181,40123,37215,21735,27309,13517,39417,153021,131183,117654,106621,71882,127726,93427,80632,70127,55773,103010,105115,71667,86902,56901,67219,68622,45292,54381,31172,47520,114408,92881,81492,68096,37751,91861,57534,49923,37880,25640,76394,65532,42342,47484,28824,40781,38074,19627,28239,12436,44186,112585,92645,81098,67970,37452,93676,57644,49516,37474,24104,79226,63557,43316,45561,29225,42216,37264,18482,28312,12360,39461,70343,56286,48145,38081,19885,54030,29094,24560,16930,8223,50844,32119,21851,20431,11975,22112,16367,6209,11906,3926,59952,171584,162083,151837,142868,109099,160600,131576,118634,106767,82007,142195,138192,113003,116740,92882,102392,106914,71223,91814,56551,81274,143802,130579,120104,104542,74464,125682,92932,81954,68341,45313,118414,98470,77773,74155,56814,71873,68243,37310,56122,30116,72981,143628,128490,120449,103861,76559,122888,92806,81469,69462,43084,121399,96727,78802,72317,56293,72447,67856,38500,56390,29276,67739,107033,86979,86065,63453,48958,80202,57594,48914,37327,18190,88822,58595,47641,37804,28677,44571,37594,18610,25971,12006,76826,143583,123651,123151,99962,81109,118939,93113,81492,68341,39972,126290,94198,80547,68054,57616,76095,67494,40625,50782,29207,74173,106872,81222,87781,62067,53496,76370,56445,48679,37102,16783,91566,56426,49719,38462,26526,48222,34403,20658,22658,11996,73657,105843,80503,89193,60233,55701,73627,56656,48408,36951,16387,92781,58036,49369,38091,24625,49709,33679,20864,21571,11932,58524,69300,42542,55087,29898,34106,38674,28733,24319,16290,8671,55486,29297,24741,16671,8696,26490,13650,8736,7628,3935,93651,143309,114149,127527,95473,89584,108224,92158,82504,68942,41932,128841,93232,82548,69119,47365,83573,61632,45394,43408,28908,85760,106068,72771,91435,57138,60841,68950,56803,50363,35724,25387,87085,57146,48704,37236,20955,52981,31461,23033,18356,11922,86269,106319,70204,91900,56371,63878,69868,53770,51317,34296,28685,84500,56852,48415,37540,20206,53778,30676,23355,17739,11943,65405,68103,36970,57371,29550,38331,37824,24246,27035,13923,18825,46099,28828,24938,16584,6574,28196,12352,10001,5878,3912,89752,106249,70707,91538,57623,65026,69280,49233,52744,32423,34130,80384,56985,48780,37159,17828,55493,29301,24242,16434,12013,69243,68368,40234,52040,29111,40052,37355,21744,27308,13510,22986,42739,28960,24374,16520,5968,28626,11956,10100,6424,3309,72363,66710,40639,50453,28974,40599,37089,20893,27975,12868,25081,40854,28851,24455,16329,5823,28663,12435,10545,5905,2880,47669,34296,20815,22003,11943,21123,17002,6927,11816,4029,14271,17731,11932,10111,5733,1850,11899,3990,3428,1545,518,148477,187481,171843,179991,162299,159200,171040,152172,157749,134509,123981,173993,161804,150022,143160,108191,162189,131665,118152,107588,84871,153362,168674,145482,154690,131323,132991,142979,112951,128194,94464,97802,143520,130685,119348,106075,72786,127537,93666,82220,68803,46457,154175,167935,146817,152867,130916,133299,143373,110591,128858,93146,100476,143838,130713,119993,104709,74240,125795,93127,81849,68412,45341,143237,136820,113887,113826,93091,103975,106018,69302,91917,58152,76067,107496,89459,84313,65652,46850,83106,56565,48636,37817,19447,162993,166481,147710,148653,130266,136101,142069,106800,131473,93841,105104,143393,126409,122066,101852,78450,119919,93952,81989,68909,41143,150587,134768,115707,108805,92321,105457,107395,70944,90607,56944,80247,107349,84045,87052,62008,51216,79360,56712,48676,36961,17739,154690,132577,116561,106105,93965,108447,105978,71660,87322,57538,82650,106767,81468,87585,62067,53586,76469,56423,48658,37138,16797,128180,92732,82160,70119,54478,78077,65716,41941,48904,28908,59658,68146,45418,54620,30747,32465,40176,28875,24373,16364,5747,181090,163250,151749,143643,127908,142526,141043,109945,122551,92666,113279,143562,117132,126443,96446,87701,111073,92538,80917,67735,39742,162790,131779,118753,106678,86741,115009,101600,74517,80278,57217,89281,106907,74584,90777,58216,59112,69858,56198,49592,37257,22898,161633,131343,118706,107194,83527,117026,99529,76722,78542,56781,91319,105997,73046,91398,57160,60834,68684,56977,50434,35737,26725,126611,93716,81533,69028,45525,85349,61725,45596,41493,28742,66373,68384,37969,56114,28695,37959,38231,26204,26343,14508,23793,158619,131197,117885,106293,79822,121584,98078,77983,73501,56571,94974,106158,68398,93420,57945,64061,69426,51268,52460,33349,35016,121710,92364,82695,69084,42213,88669,58714,47437,38474,28740,68000,68476,39435,54885,29402,38955,37746,23076,27122,13562,31191,119652,93660,81673,68657,40410,90233,57781,47964,37260,28665,70937,68508,40108,52236,29006,40066,37440,21759,27301,13495,30080,77708,56859,48443,37239,17196,55851,28934,24307,17454,11119,46241,35226,19514,23956,12005,21050,16419,7576,11761,4160,43135,177342,161946,151204,142783,108679,159761,130767,119280,107503,90411,132433,141217,109895,123651,93162,98938,106979,79060,89445,59679,68946,149253,130609,117529,105787,68068,131967,94198,82416,69426,50747,109144,102454,74286,81102,56966,69529,68761,41974,55178,29917,60210,146509,130307,116927,106921,71092,130028,93772,81772,69678,48651,112149,100747,74545,80410,56895,70278,68572,40126,55746,29247,58009,106800,93004,83193,67823,42516,88303,57230,49138,37264,21485,82476,62409,45345,42458,28830,42776,37409,17006,28652,11944,62058,143848,130873,119846,104906,74029,125851,93338,81849,68341,45412,117993,98511,77998,74359,56694,71916,68137,37494,56132,29937,64222,107420,89647,84418,65547,46760,83295,56543,48454,38014,19469,87381,59259,46773,39415,28712,43745,36757,17458,28457,12052,62803,107068,87000,86149,63494,48742,80590,57402,48977,37355,18291,88505,58882,47619,37848,28687,44055,37930,18637,26106,12015,51651,69462,48089,53138,32019,28939,44432,28837,24550,16366,6200,55665,29082,24253,16366,12205,24337,15445,7730,9084,3990,79887,143204,121402,123362,100388,82994,116473,92771,81309,68677,38302,128164,92816,81894,70169,54554,78127,65785,41717,49150,28907,76546,106264,80404,89053,60450,55443,73710,56894,48409,36923,16433,92294,58168,49600,38056,24774,49399,33939,20759,21735,11933,76233,107328,77434,89979,58949,57594,71973,56364,48265,36727,18961,92730,57524,49174,37144,23956,50751,32692,21352,20872,12087,60546,68944,40768,55559,29580,34766,37752,28676,25254,16298,10821,53231,28953,24955,16655,8002,26797,13333,9464,6913,3923,82462,105802,73346,91392,57138,60813,68440,57138,50532,35737,25051,87246,57217,48655,37432,20987,52732,31656}; int t[2]; bool pd(int x){ t[0]=t[1]=0; while(x) ++t[x&1],x>>=1; return t[0]>=t[1]; } int cal(int x){ int tmp=x/200000,ans=0; rep(i,1,tmp) ans+=a[i]; rep(i,x/200000*200000+1,x) if(pd(i)) ans++; return ans; } int main(){ int n,m;scanf("%d%d",&n,&m); printf("%d ",cal(m)-cal(n-1)); return 0; }
bzoj1661:
O(n4)暴力枚举
#include<cstdio> #include<cstring> #include<iostream> #include<algorithm> using namespace std; #define rep(i,s,t) for(int i=s;i<=t;i++) #define dwn(i,s,t) for(int i=s;i>=t;i--) #define clr(x,c) memset(x,c,sizeof(x)) const int nmax=105; int map[nmax][nmax]; char s[nmax]; int main(){ int n;scanf("%d",&n); rep(i,1,n){ scanf("%s",s+1); rep(j,1,n) if(s[j]=='J') map[i][j]=2; else if(s[j]=='*') map[i][j]=1; else map[i][j]=0; } int x,y,ans=0; rep(i,1,n) rep(j,1,n) if(map[i][j]==2){ rep(k,1,n) rep(t,1,n) if(map[k][t]){ if(k==i&&t==j) continue; x=i-k,y=j-t; if(x*x+y*y<=ans) continue; if(i+y<=n&&k+y<=n&&j-x<=n&&t-x<=n&&i+y>0&&k+y>0&&j-x>0&&t-x>0&&map[i+y][j-x]==2&&map[k+y][t-x]==2) ans=x*x+y*y; x=k-i,y=t-j; if(i+y<=n&&k+y<=n&&j-x<=n&&t-x<=n&&i+y>0&&k+y>0&&j-x>0&&t-x>0&&map[i+y][j-x]==2&&map[k+y][t-x]==2) ans=x*x+y*y; } } printf("%d ",ans); return 0; } /* 6 J*J*** ****** J***J* ****** ****** ****** */
bzoj1660:
又是单调栈。。。我。。。
#include<cstdio> #include<cstring> #include<iostream> #include<algorithm> using namespace std; #define rep(i,s,t) for(int i=s;i<=t;i++) #define dwn(i,s,t) for(int i=s;i>=t;i--) #define clr(x,c) memset(x,c,sizeof(x)) #define ll long long const int nmax=80005; int a[nmax],s[nmax]; int main(){ ll ans=0; int n;scanf("%d",&n); rep(i,1,n) scanf("%d",&a[i]); s[1]=1;ll r=1; rep(i,2,n){ while(r&&a[s[r]]<=a[i]) r--; ans+=r;s[++r]=i; } printf("%lld ",ans); return 0; }
bzoj1657:
还是单调栈。。。我。。。
#include<cstdio> #include<cstring> #include<iostream> #include<algorithm> using namespace std; #define rep(i,s,t) for(int i=s;i<=t;i++) #define dwn(i,s,t) for(int i=s;i>=t;i--) #define clr(x,c) memset(x,c,sizeof(x)) int x;char c; int read(){ x=0;c=getchar(); while(!isdigit(c)) c=getchar(); while(isdigit(c)) x=x*10+c-'0',c=getchar(); return x; } const int nmax=50005; int h[nmax],v[nmax],s[nmax],ans[nmax]; int main(){ int N=read(); rep(i,1,N) h[i]=read(),v[i]=read(); s[1]=1;;int r=1; rep(i,2,N){ while(r&&h[s[r]]<h[i]) ans[i]+=v[s[r]],r--; s[++r]=i; } s[1]=N;r=1; dwn(i,N-1,1){ while(r&&h[s[r]]<h[i]) ans[i]+=v[s[r]],r--; s[++r]=i; } int res=0; rep(i,1,N) res=max(res,ans[i]); printf("%d ",res); return 0; }
bzoj1655:
背包dp+高精度。。。看清楚数据范围看清楚数据范围看清楚数据范围!!!
#include<cstdio> #include<cstring> #include<iostream> #include<algorithm> using namespace std; #define rep(i,s,t) for(int i=s;i<=t;i++) #define dwn(i,s,t) for(int i=s;i>=t;i--) int dp[1005][1005]; void add(int x,int y){ rep(i,1,dp[y][0]) dp[x][i]+=dp[y][i]; dp[x][0]=max(dp[x][0],dp[y][0]); rep(i,1,dp[x][0]) if(dp[x][i]>=10) dp[x][i]-=10,dp[x][i+1]++; if(dp[x][dp[x][0]+1]) dp[x][0]++; } int main(){ int n,k;scanf("%d%d",&n,&k); dp[0][0]=dp[0][1]=1; rep(i,1,k) rep(j,i,n) add(j,j-i); dwn(i,dp[n][0],1) printf("%d",dp[n][i]); return 0; }
bzoj1654:
tarjan即可
#include<cstdio> #include<cstring> #include<iostream> #include<algorithm> #include<stack> using namespace std; #define rep(i,s,t) for(int i=s;i<=t;i++) #define dwn(i,s,t) for(int i=s;i>=t;i--) #define clr(x,c) memset(x,c,sizeof(x)) #define qwq(x) for(edge *o=head[x];o;o=o->next) int read(){ int x=0;char c=getchar(); while(!isdigit(c)) c=getchar(); while(isdigit(c)) x=x*10+c-'0',c=getchar(); return x; } const int nmax=10005; const int maxn=50005; const int inf=0x7f7f7f7f; struct edge{ int to;edge *next; }; edge edges[maxn],*pt=edges,*head[nmax]; void add(int u,int v){ pt->to=v;pt->next=head[u];head[u]=pt++; } int sccno[nmax],pre[nmax],ans=0,dfs_clock=0,scc_cnt=0; stack<int>s; int dfs(int x){ int lowu=pre[x]=++dfs_clock;s.push(x); qwq(x) { int to=o->to; if(!pre[to]) lowu=min(lowu,dfs(to)); else if(!sccno[to]) lowu=min(lowu,pre[to]); } if(lowu==pre[x]){ int sum=0;scc_cnt++; while(1){ sum++; int X=s.top();s.pop(); sccno[X]=scc_cnt; if(x==X) break; } if(sum!=1) ans++; } return lowu; } int main(){ int N=read(),M=read(),u,v; rep(i,1,M) u=read(),v=read(),add(u,v); rep(i,1,N) if(!pre[i]) dfs(i); printf("%d ",ans); return 0; }
bzoj1653:
N很小,求出所有全排列后利用杨辉三角形计算次数即可
#include<cstdio> #include<cstring> #include<iostream> #include<algorithm> using namespace std; #define rep(i,s,t) for(int i=s;i<=t;i++) #define dwn(i,s,t) for(int i=s;i>=t;i--) #define clr(x,c) memset(x,c,sizeof(x)) int a[11],dp[11][11]; int main(){ int n,m,tmp;scanf("%d%d",&n,&m); rep(i,1,n) a[i]=i; dp[1][1]=1; rep(i,2,n) rep(j,1,i) dp[i][j]=dp[i-1][j]+dp[i-1][j-1]; while(1){ tmp=0; rep(i,1,n) tmp+=a[i]*dp[n][i]; if(tmp==m) break; next_permutation(a+1,a+n+1); } printf("%d",a[1]); rep(i,2,n) printf(" %d",a[i]); printf(" "); return 0; }
bzoj1652:
和做过的差不多,可以压掉一维不会空间没炸就没压了。。。
#include<cstdio> #include<cstring> #include<iostream> #include<algorithm> using namespace std; #define rep(i,s,t) for(int i=s;i<=t;i++) #define dwn(i,s,t) for(int i=s;i>=t;i--) #define clr(x,c) memset(x,c,sizeof(x)) const int nmax=2005; int a[nmax],f[nmax][nmax]; int main(){ int n;scanf("%d",&n); rep(i,1,n) scanf("%d",&a[i]); rep(i,1,n) { for(int j=1;j+i-1<=n;j++){ f[j][j+i-1]=max(f[j+1][j+i-1]+(n-i+1)*a[j],f[j][j+i-2]+(n-i+1)*a[j+i-1]); } } printf("%d ",f[1][n]); return 0; }
bzoj1651:
差分序列即可
#include<cstdio> #include<cstring> #include<iostream> #include<algorithm> using namespace std; #define rep(i,s,t) for(int i=s;i<=t;i++) #define dwn(i,s,t) for(int i=s;i>=t;i--) #define clr(x,c) memset(x,c,sizeof(x)) int read(){ int x=0;char c=getchar(); while(!isdigit(c)) c=getchar(); while(isdigit(c)) x=x*10+c-'0',c=getchar(); return x; } const int nmax=1000005; int a[nmax]; int main(){ int N=read(),u,v,tot=-1,ans=0; rep(i,1,N) u=read(),v=read(),a[u]+=1,a[v+1]-=1,tot=max(tot,v); rep(i,1,tot) ans=max(ans,a[i]+=a[i-1]); printf("%d ",ans); return 0; }
❤bzoj1649:
跟背包dp差不多
#include<cstdio> #include<cstring> #include<iostream> #include<algorithm> using namespace std; #define rep(i,s,t) for(int i=s;i<=t;i++) #define dwn(i,s,t) for(int i=s;i>=t;i--) #define clr(x,c) memset(x,c,sizeof(x)); int read(){ int x=0;char c=getchar(); while(!isdigit(c)) c=getchar(); while(isdigit(c)) x=x*10+c-'0',c=getchar(); return x; } const int nmax=1005; int dp[nmax][nmax]; struct node{ int s,t,w,c; bool operator<(const node&rhs)const{ return s<rhs.s||s==rhs.s&&t<rhs.t;} }; node nodes[nmax*10]; int main(){ int L=read(),N=read(),B=read(); rep(i,1,N) { node &o=nodes[i]; o.s=o.t=read(),o.t+=read(),o.w=read(),o.c=read(); } sort(nodes+1,nodes+N+1); clr(dp,-1);dp[0][0]=0; rep(i,1,N) dwn(j,B,nodes[i].c) if(dp[nodes[i].s][j-nodes[i].c]!=-1) dp[nodes[i].t][j]=max(dp[nodes[i].s][j-nodes[i].c]+nodes[i].w,dp[nodes[i].t][j]); int ans=-1; rep(i,1,B) if(dp[L][i]!=-1) ans=max(ans,dp[L][i]); printf("%d ",ans); return 0; }