其他分享
首页 > 其他分享> > CCPC2018-湖南全国邀请赛-重现赛(感谢湘潭大学)【补题】

CCPC2018-湖南全国邀请赛-重现赛(感谢湘潭大学)【补题】

作者:互联网

目录

A - Easy $h$-index HDU - 6276

B - Higher $h$-index HDU - 6277

F - Sorting HDU - 6281

G - String Transformation HDU - 6282

J - Vertex Cover HDU - 6285

K - 2018 HDU - 6286


A - Easy $h$-index HDU - 6276

#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int N=2e5+5;

int a[N];

int main(){
    int n;
    while(~scanf("%d",&n)){
        memset(a,0,sizeof(a));
        for(int i=0;i<=n;i++){
            scanf("%d",&a[i]);
        }
        int res=0;
        for(int i=n;i>=0;i--){
            res=res+a[i];
            if(res>=i){
                printf("%d\n",i);
                break;
            }
        }
    }
    return 0;
}

B - Higher $h$-index HDU - 6277

#include<cstdio>
typedef long long ll;


int main(){
	int n,a;
	while(~scanf("%d%d",&n,&a)){
//		if(a==0){
//			printf("1\n");
//			continue;
//		}
		
		printf("%lld\n",(n+a)/2);
	}
	return 0;
}

F - Sorting HDU - 6281

#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;

struct Node{
	int id;
	ll a,b,c;
}p[1005];

bool cmp1(Node s1,Node s2){
	ll s=(s1.a+s1.b)*s2.c;
	ll ss=(s2.a+s2.b)*s1.c;

	if(s==ss)
		return s1.id<s2.id;
	return s<ss;
}

int main(){
	int n;
	while(~scanf("%d",&n)){
		for(int i=0;i<n;i++){
			scanf("%lld%lld%lld",&p[i].a,&p[i].b,&p[i].c);
			p[i].id=i+1;
		}

		sort(p,p+n,cmp1);
		
		for(int i=0;i<n;i++)
			printf("%d%c",p[i].id,i==n-1?'\n':' ');	
	}
	return 0;
}

G - String Transformation HDU - 6282

#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<iostream>
using namespace std;
const int N=1e4+5;
string s,t;
int ss[N],tt[N];

int main(){
	while(cin>>s>>t){
		int ls=s.length(),lt=t.length();
		int lens=0,lent=0;
		int sum=0;
		for(int i=0;i<ls;i++){
			if(s[i]=='c')
				 ss[lens++]=sum;
			sum^=s[i];
		}
		ss[lens++]=sum;
		sum=0;
		for(int i=0;i<lt;i++){
			if(t[i]=='c')
				 tt[lent++]=sum;
			sum^=t[i];
		}
		tt[lent++]=sum;
		if(lens!=lent)
			printf("No\n");
		else{
			int f=0;
			for(int i=0,j=0;i<lens;i++,j++){
				if(ss[i]!=tt[i]){
					f=1;break;
				}
			}
			if(f) printf("No\n");
			else printf("Yes\n");
		}	
	}
	return 0;
}

J - Vertex Cover HDU - 6285

#include<cstdio>
#include<cstring>
using namespace std;
typedef long long ll;
const int N=1e5+5;
const ll mod=1e9+7;

ll f[N];
void init(){
	f[0]=1;
	for(int i=1;i<N;i++)
		f[i]=(f[i-1]*2)%mod;
}

int main(){
	int n;
	char k[N];
	init();
	while(~scanf("%d%s",&n,&k)){
		int len=strlen(k);
		int len1=n-len;
		
		ll ans=1;
		for(int i=0;i<len;i++)
			if(k[i]=='1')
				ans=ans*(f[len1]-1)%mod*f[len-1-i]%mod;
			else len1++;
		printf("%lld\n",ans);
	}
	return 0;
} 

K - 2018 HDU - 6286

#include<cstdio>
typedef long long ll;

ll work(int a,int b){
	ll x=a/2018;
	ll y=a/1009-x;
	ll z=a/2-x;
	return b*x+b/2*y+b/1009*z+b/2018*(a-x-y-z);
}

int main(){
	int a,b,c,d;
	while(~scanf("%d%d%d%d",&a,&b,&c,&d)){
		ll ans=work(b,d)-work(a-1,d)-work(b,c-1)+work(a-1,c-1);
		printf("%lld\n",ans);
	}
	return 0;
}

 

标签:CCPC2018,HDU,int,ll,work,long,补题,include,邀请赛
来源: https://blog.csdn.net/lidengdengter/article/details/94963751