The 2018 ACM-ICPC Asia Qingdao Regional Contest
Posted dyloder
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了The 2018 ACM-ICPC Asia Qingdao Regional Contest相关的知识,希望对你有一定的参考价值。
The 2018 ACM-ICPC Asia Qingdao Regional Contest
青岛总体来说只会3题
C
#include<bits/stdc++.h> using namespace std; #define maxn 3000005 char a[maxn],b[maxn]; int c[maxn],ll[maxn],rr[maxn]; int main(){ int t; cin>>t; while(t--){ int n; scanf("%d",&n); scanf("%s",a); scanf("%s",b); for(int j=0;j<n;j++){ if(a[j]!=b[j]){ c[j]=1; }else c[j]=0; } int i=0; bool fa=0; for(int j=0;j<strlen(a);j++){ //if(fa&&c[j]==1) continue; if(fa==1&&c[j]==0){ rr[i-1]=j; fa=0; }else if(fa==0&&c[j]==1){ ll[i]=j; i++; fa=1; } } if(c[n-1]==1) rr[i-1]=n-1; if(i==0){ printf("%lld ",1LL*n*(n+1)/2); }else if(i==1){ int k=rr[i-1]-ll[i-1]+1; long long ans=1LL*(k-1)*2+1LL*(n-k)*2; printf("%lld ",ans); }else if(i==2){ printf("6 "); }else{ printf("0 "); } } return 0; }
E
#include<bits/stdc++.h> using namespace std; #define maxn 200005 #define LL long long LL a[maxn],b[maxn]; LL n,m; bool fa(LL x){ LL ans=0; for(int j=0;j<n;j++){ if(x%a[j]==0){ b[j]=x/a[j]; }else{ b[j]=x/a[j]+1; } } for(int j=0;j<n;j++){ if(j==n-1&&b[j]<1) break; ans++; if(b[j]>1){ ans+=(b[j]-1)*2; b[j+1]-=b[j]-1; } if(ans>m) return 0; } return 1; } int main(){ int t; cin>>t; while(t--){ scanf("%lld%lld",&n,&m); LL mx=0; for(int j=0;j<n;j++){ scanf("%lld",&a[j]); mx=max(mx,a[j]); } LL l=0,r=mx*m; if(m==0) cout<<"0"<<endl; else{ while(l<r){ LL mid=(r+l)/2; if(fa(mid)) l=mid+1; else r=mid; } printf("%lld ",max(1LL*0,l-1)); } } return 0; }
J
#include<bits/stdc++.h> using namespace std; typedef long long LL; const int maxn = 100010; int Min( int a , int b ){ return a<b?a:b; } int n,m,a[maxn]; int main() { int T; scanf( "%d" , &T ); for( int cas=1 ; cas<=T ; cas++ ) { int cnt = 0,num = 0; scanf ( "%d%d" , &n , &m ); for( int i=1 ; i<=n ; i++ ) { int x; scanf( "%d" , &x ); if ( x==0 ) cnt++; else a[++num] = x; } if ( m==n ) printf( "Richman " ); else if ( m<cnt ) printf( "Impossible " ); else { LL ans = 0; int tmp = 2000000000; for( int i=1 ; i<=num ; i++ ) { if ( i<=m-cnt ) ans += a[i]; else tmp = Min( tmp , a[i] ); } printf( "%lld " , ans+tmp-1 ); } } return 0; }
M
#include<bits/stdc++.h> using namespace std; #define LL long long int fa[12]={1,0,0,0,1,0,1,0,2,1}; int main(){ int t; cin>>t; while(t--){ int n,z; scanf("%d%d",&n,&z); //cout<<"2"<<endl; while(1){ if(n==1||n==0) break; if(z<=0) break; int i=0; int k=n; while(k>0){ LL ii=k%10; i+=fa[ii]; k/=10; } n=i; z--; } if(z==0){ printf("%d ",n); }else{ if(z%2==0){ printf("%d ",n); }else{ printf("%d ",fa[n]); } } } }
以上是关于The 2018 ACM-ICPC Asia Qingdao Regional Contest的主要内容,如果未能解决你的问题,请参考以下文章
The 2018 ACM-ICPC Asia Qingdao Regional Contest
The 2018 ACM-ICPC Asia Qingdao Regional Contest, Online J Press the Button
The 2018 ACM-ICPC Asia Beijing Regional Contest
The 2018 ACM-ICPC Asia Qingdao Regional Contest K XOR Clique
The 2018 ACM-ICPC Asia Qingdao Regional Contest, Online - H Traveling on the Axis-思维模拟题目
I. Distance (模拟)2018-2019 ACM-ICPC, Asia Jiaozuo Regional Contest