「JoyOI」五月有奖赛 暨Loi 55 Round #1 Day1
题解
http://pan.baidu.com/s/1bnjO0ij
选择题(by Darkfalmes)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
#include<cmath> #include<cstdio> #include<cstring> #include<iostream> #include<algorithm> #define ll long long #define inf 1000000000 #define mod 1000000000 using namespace std; int read() { int x=0,f=1;char ch=getchar(); while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();} while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();} return x*f; } int n,ans; int a[500005],c[500005],f[500005][4]; char ch[2]; int main() { n=read(); for(int i=1;i<=n;i++) { scanf("%s",ch); a[i]=ch[0]-'A'; c[i]=read(); } for(int i=0;i<n;i++) for(int j=0;j<4;j++) { if(j==a[i])f[i][j]+=c[i]; for(int k=-1;k<=1;k++) if(0<=j+k&&j+k<4)f[i+1][j+k]=max(f[i+1][j+k],f[i][j]); } f[n][a[n]]+=c[n]; for(int i=0;i<4;i++)ans=max(ans,f[n][i]); printf("%d\n",ans); return 0; } |
王的对决!(by rainheart & seavot)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
#include<cmath> #include<cstdio> #include<cstring> #include<iostream> #include<algorithm> #define ll long long #define inf 1000000000 #define mod 1000000000 using namespace std; int read() { int x=0,f=1;char ch=getchar(); while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();} while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();} return x*f; } int T,n,m,tot; int mu[1500005],f[1500005],pri[1500005]; ll ans,F[1500005]; bool mark[1500005]; void pre() { mu[1]=1; for(int i=2;i<=1500000;i++) { if(!mark[i])pri[++tot]=i,mu[i]=-1; for(int j=1;j<=tot&&i*pri[j]<=1500000;j++) { mark[i*pri[j]]=1; if(i%pri[j]==0){mu[i*pri[j]]=0;break;} else mu[i*pri[j]]=-mu[i]; } } for(int i=1;i<=1500000;i++) if(mu[i])f[i]=i; for(int i=1;i<=1500000;i++) if(f[i]) for(int j=1;j*i<=1500000;j++) F[j*i]+=f[i]*mu[j]; for(int i=1;i<=1500000;i++)F[i]+=F[i-1]; } int main() { pre(); T=read(); while(T--) { ans=0; n=read();m=read(); if(n>m)swap(n,m); for(int i=1,j;i<=n;i=j+1) { j=min(n/(n/i),m/(m/i)); ans+=(F[j]-F[i-1])*(n/i)*(m/i); } printf("%lld\n",ans); } return 0; } |
dC的肥皂(by skyfall(Orz))
60暴力
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
#include<set> #include<map> #include<ctime> #include<queue> #include<cmath> #include<cstdio> #include<vector> #include<cstring> #include<cstdlib> #include<iostream> #include<algorithm> #define ll long long #define inf 1000000000 using namespace std; int read() { int x=0,f=1;char ch=getchar(); while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();} while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();} return x*f; } int x,y,K; int T,n,m,cnt,lastans; int last[100005],q1[100005],q2[100005],Log[100005],dis[100005]; bool mark[100005]; struct edge{ int to,next,v; }e[200005]; void insert(int u,int v,int w) { e[++cnt]=(edge){v,last[u],w};last[u]=cnt; e[++cnt]=(edge){u,last[v],w};last[v]=cnt; } void bfs(int *q,int x) { int head=1,tail=2; q[1]=x;dis[x]=0; while(head!=tail) { int now=q[head];head++;mark[now]=1; for(int i=last[now];i;i=e[i].next) if(dis[now]+e[i].v<=K&&!mark[e[i].to]) { q[tail++]=e[i].to; dis[e[i].to]=dis[now]+e[i].v; } } q[0]=tail-1; } void solve(int x,int y,int K) { bfs(q1,x); for(int i=1;i<=q1[0];i++)mark[q1[i]]=0; bfs(q2,y); for(int i=1;i<=q1[0];i++) if(mark[q1[i]])lastans++; for(int i=1;i<=q2[0];i++)mark[q2[i]]=0; } int main() { n=read(); for(int i=1;i<n;i++) { int u=read(),v=read(),w=read(); insert(u,v,w); } m=read(); for(int i=1;i<=m;i++) { x=read();y=read();K=read(); x^=lastans;y^=lastans;K^=lastans; lastans=0; solve(x,y,K); printf("%d\n",lastans); } return 0; } |
DQS和序列(by 帝江&Darkfalmes)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
#include<cmath> #include<cstdio> #include<cstring> #include<iostream> #include<algorithm> #define ll long long #define inf 1000000000 using namespace std; ll read() { ll x=0,f=1;char ch=getchar(); while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();} while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();} return x*f; } int n,m; struct data{ int l,r; ll sum,mx,v; }t[400005]; void build(int k,int l,int r) { t[k].l=l;t[k].r=r;int mid=(l+r)>>1; if(l==r){t[k].mx=t[k].v=t[k].sum=read();return;} build(k<<1,l,mid); build(k<<1|1,mid+1,r); t[k].mx=max(t[k<<1].mx,t[k<<1|1].mx); t[k].sum=t[k<<1].sum+t[k<<1|1].sum; } void modify(int k,int x,int y,int val,int f)//0修改1取模 { int l=t[k].l,r=t[k].r,mid=(l+r)>>1; if(f==1&&t[k].mx<val)return; if(l==r) { if(f==1) { t[k].v%=val; t[k].sum=t[k].mx=t[k].v; } else t[k].v=t[k].mx=t[k].sum=val; return; } if(x<=mid)modify(k<<1,x,min(mid,y),val,f); if(y>mid)modify(k<<1|1,max(mid+1,x),y,val,f); t[k].mx=max(t[k<<1].mx,t[k<<1|1].mx); t[k].sum=t[k<<1].sum+t[k<<1|1].sum; } ll query(int k,int x,int y) { int l=t[k].l,r=t[k].r,mid=(l+r)>>1; if(l==x&&y==r)return t[k].sum; ll ans=0; if(x<=mid)ans+=query(k<<1,x,min(mid,y)); if(y>mid)ans+=query(k<<1|1,max(mid+1,x),y); return ans; } int main() { n=read();m=read(); build(1,1,n); int opt,l,r,x; while(m--) { opt=read(); if(opt==1) { l=read();r=read(); printf("%I64d\n",query(1,l,r)); } if(opt==2) { l=read();r=read();x=read(); modify(1,l,r,x,1); } if(opt==3) { l=read();x=read(); modify(1,l,l,x,0); } } return 0; } |
请问题解的提取密码多少
丫我不知道。。。