我是靠谱客的博主 无奈溪流,最近开发中收集的这篇文章主要介绍2019 ECNU Campus Invitational Contest(Gym 2019上海游族杯ecnu部分题解),觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

官方题解
以下为个人题解

题面描述

A 直接根据长度瞎搞搞就行

#include<iostream>
#include<cstring>
#include<cstdio>
#include<queue>
#include<cstdlib>
#include<cmath>
#include<stack>
#include<map>
#include<vector>
#include<algorithm>
using namespace std;
#define INF 0x3f3f3f3f
#define ll long long
#define endl 'n'
const double pi = acos(-1);
const int maxn = 10 + 10;
const int maxm = 5e5 + 10;
const int mod = 1e9 + 7;
char s[maxn];

int main()
{
    scanf("%s", s);
    int len = strlen(s);
    if(len == 5){
        int a = (s[0]-'0')*10+s[1]-'0';
        int b = (s[2]-'0')*10+s[3]-'0';
        int c = s[4]-'0';
        printf("%d", (b+12-a)*c);
    }
    else if(len == 4){
        if(s[0] == '1'){
            int a = (s[0]-'0')*10+s[1]-'0';
            int b = s[2]-'0';
            int c = s[3]-'0';
            printf("%d", (b+12-a)*c);
        }
        else{
            int a = s[0] - '0';
            int b = (s[1]-'0')*10+s[2]-'0';
            int c = s[3]-'0';
            printf("%d", (b+12-a)*c);
        }
    }
    else if(len == 3){
        int a = s[0]-'0';
        int b = s[1]-'0';
        int c = s[2]-'0';
        printf("%d", (b+12-a)*c);
    }
    return 0;
}

B 概率dp

对于鬼牌是否在手中进行讨论即可

#include<iostream>
#include<cstring>
#include<cstdio>
#include<queue>
#include<cstdlib>
#include<cmath>
#include<stack>
#include<map>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
#define ll long long
#define INF 0x3f3f3f3f
#define endl 'n'
const double pi = acos(-1);
const int maxn = 1e6 + 10;
const int maxm = 5e5 + 10;
double dp[maxn][3];
char a[maxn], b[maxn];
int t, flag, n, cnt;
void init(){
    dp[0][0] = 1;//鬼牌在对面,双方都没有其他牌我必赢
    dp[0][1] = 0;//鬼牌在自己手上,双方都没有其他牌我必输
    for(int i = 1 ; i <= maxn ; ++ i){
        dp[i][1] = 1 - dp[i-1][0];
        //dp[i][0] = 1 / (i + 1) * (1 - dp[i][0]) +
        //i / (i + 1) * (1 - dp[i-1][1])
        dp[i][0] = (1 + i - i * dp[i-1][1] * 1.0) / (i + 2);
    }
}
int main(){

    scanf("%d", &t);
    init();
    while(t--){
        scanf("%d", &n);
        scanf("%s", a);
        scanf("%s", b);
        cnt = 0;
        for(int i = 0 ; i < strlen(a) ; ++ i){
            if(a[i] == '1' && b[i] == '0'){
                flag = 1;
            }
            else if(a[i] == '0' && b[i] == '1'){
                flag = 0;
            }
            else if(a[i] == '1' && b[i] == '1'){
                cnt ++;
            }
        }
        printf("%.9lfn", dp[cnt][flag]);
    }
	return 0;
}

F map直接按题意弄

#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn = 500 + 5;
const int INF = 5e6;
int t;
ll ans;
vector<string> v;
map<string, int> ma;
int main(){
	scanf("%d", &t);
	getchar();
	while(t--){
        string tmp = "";
        char ch = getchar();
        if(ch == 'n') continue;
        if(ch <= 'Z' && ch >= 'A')
        tmp += ch;
        while(ch != 'n'){
            if(ch == ' '){
                ch = getchar();
                if(ch <= 'Z' && ch >= 'A')
                tmp += ch;
            }
            else ch = getchar();
        }
        if(tmp == "") continue;
        ma[tmp] ++;
        if(ma[tmp] == 1){
            v.push_back(tmp);
        }
	}
	for(int i = 0 ; i < v.size() ; ++ i){
        ans += (ll)(ma[v[i]]-1)*ma[v[i]] / 2;
	}
	cout << ans;
	return 0;
}

H 数学推理

#include<bits/stdc++.h>
using namespace std;
#define maxn 300005
#define ll long long

ll n,m;
ll sum;
int main()
{
	scanf("%lld %lld",&n,&m);
	/*for(int i=0;i<n;i++){
		if(m>i)sum+=m-i;
		else break;
	}*/
	if(m>=n)sum=(2*m-n+1)*n/2;
	else sum=(m+1)*m/2;
	ll g=__gcd(sum,n*m);
	printf("%lld/%lld",sum/g,n*m/g);
	return 0;
}

I 对于-1取正无穷跑一遍floyed

#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn = 500 + 5;
const int INF = 5e6;
int a[maxn][maxn], b[maxn][maxn];
int t, n;1111
int main(){
	scanf("%d", &t);
	while(t--){
        scanf("%d", &n);
        int flag = 0;
        for(int i = 1 ; i <= n ; ++ i){
            for(int j = 1 ; j <= n ; ++ j){
                scanf("%d", &a[i][j]);
                b[i][j] = a[i][j];
            }
        }
        for(int i = 1 ; i <= n ; ++ i){
            b[i][i] = 0;
            for(int j = 1 ; j <= n ; ++ j){
                if(b[i][j] != b[j][i] && b[i][j] != -1 && b[j][i] != -1) flag = 1;
                if(b[i][j] == -1 && b[j][i] != -1) b[i][j] = b[j][i];
                else if(b[i][j] == -1) b[i][j] = INF;
            }
        }

        for(int k = 1 ; k <= n ; ++ k)
            for(int i = 1 ; i <= n ; ++ i)
                for(int j = 1 ; j <= n ; ++ j)
                    b[i][j] = min(b[i][k] + b[k][j], b[i][j]);
        for(int i = 1 ; i <= n ; ++ i){
            for(int j = 1 ; j <= n ; ++ j){
                if(b[i][j] != a[i][j] && a[i][j] != -1){
                    flag = 1;
                    //cout << "***" << b[i][j] << ' ' << a[i][j] << ' ' << i << ' ' << j << endl;
                    break;
                }
            }
            if(flag) break;
        }
        //cout << flag << "**" << endl;
        if(flag) cout << "NO" << endl;
        else{
            cout << "YES" << endl;
            for(int i = 1 ; i <= n ; ++ i){
                for(int j = 1 ; j <= n ; ++ j){
                    printf("%d%c", b[i][j], j == n ? 'n' : ' ');
                }
            }
        }
	}
	return 0;
}

L 被自己蠢到了,其实只要没几行

#include<bits/stdc++.h>
using namespace std;
#define maxn 300005
#define ll long long

int t;
int a[7];
ll sum;
int minn(int a,int b,int c){
	b=min(a,b);
	c=min(b,c);
	return c; 
}
int main()
{
	scanf("%d",&t);
	while(t--){
		sum=0;
		for(int i=1;i<=6;i++)
			scanf("%d",&a[i]);
		sum+=a[6];
		a[6]=0;
		int m15=min(a[1],a[5]);
		sum+=m15;
		a[1]-=m15,a[5]-=m15;
		if(a[5]>0){
			sum+=a[5];
			a[5]=0;
			int m24=min(a[2],a[4]);
			sum+=m24;
			a[2]-=m24,a[4]-=m24;
			if(a[4]>0){
				int m14=min(a[1]/2,a[4]);
				sum+=m14;
				a[1]-=m14*2,a[4]-=m14;
				if(a[4]>0){
					sum+=a[4];
					sum+=(a[3]+1)/2;
				}
				else{
					sum+=a[3]/2;
					a[3]%=2;
					if(a[3]==1){
						if(a[1]<=3){
							sum++;
							a[1]=a[3]=0;
						}
						else{
							sum=sum+1;
							a[1]-=3;
							a[3]=0;
							sum+=(a[1]+5)/6;
							a[1]=0;
						}
					}
					else {
						sum+=(a[1]+5)/6;
						a[1]=0;
					}
				}
			}
			else{
				sum+=a[3]/2;
				a[3]%=2;
				sum+=(3*a[3]+2*a[2]+a[1]+5)/6;
			}
		}
		else{
			int m24=min(a[2],a[4]);
			sum+=m24;
			a[2]-=m24,a[4]-=m24;
			if(a[4]>0){
				int m14=min(a[1]/2,a[4]);
				sum+=m14;
				a[1]-=m14*2,a[4]-=m14;
				if(a[4]>0){
					sum+=a[4];
					sum+=(a[3]+1)/2;
				}
				else{
					sum+=a[3]/2;
					a[3]%=2;
					if(a[3]==1){
						if(a[1]<=3){
							sum++;
							a[1]=a[3]=0;
						}
						else{
							sum=sum+1;
							a[1]-=3;
							a[3]=0;
							sum+=(a[1]+5)/6;
							a[1]=0;
						}
					}
					else {
						sum+=(a[1]+5)/6;
						a[1]=0;
					}
				}
			}
			else{
				sum+=a[3]/2;
				a[3]%=2;
				sum+=(3*a[3]+2*a[2]+a[1]+5)/6;
			}
		}
		printf("%lldn",sum);
	}
	return 0;
}

最后

以上就是无奈溪流为你收集整理的2019 ECNU Campus Invitational Contest(Gym 2019上海游族杯ecnu部分题解)的全部内容,希望文章能够帮你解决2019 ECNU Campus Invitational Contest(Gym 2019上海游族杯ecnu部分题解)所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(62)

评论列表共有 0 条评论

立即
投稿
返回
顶部