• Codeforces Round #619 (Div. 2)


    contest

    A

    #include <iostream>
    #include <algorithm>
    #include <string>
    #include <vector>
    using namespace std;
    string a, b , c;
    void work()
    {
    	for(int i = 0;i < a.size();i ++)
    	{
    		if(c[i] != a[i] && c[i] != b[i])
    		{
    			cout << "NO" << endl;
    			return;
    		}
    	}
    	cout << "YES" << endl;
    }
    int main()
    {
    	int t = 0;
    	cin >> t;
    	while(t--)
    	{
    		cin >> a >> b >> c;
    		work();
    	}
    	return 0;
    }
    

    B

    #include <iostream>
    #include <algorithm>
    #include <string>
    #include <vector>
    using namespace std;
    const int N = 100005;
    int arr[N], n;
    
    void work()
    {
    	int base = 0;
    	vector<int> v;
    	for(int i = 0;i < n - 1;i ++)
    	{
    		if(arr[i] == -1 && arr[i + 1] != -1)v.push_back(arr[i + 1]);
    		else if(arr[i] != -1 && arr[i + 1] == -1)v.push_back(arr[i]);
    		else if(arr[i] != -1 && arr[i + 1] != -1)base = max(base,abs(arr[i] - arr[i + 1]));
    	}	
    	if(v.empty())
    	{
    		printf("0 0
    ");
    		return;
    	}
    	sort(v.begin(),v.end());
    	int k = (v.back() + *v.begin()) / 2;
    	printf("%d %d
    ",max({v.back() - k, k - v[0], base}),k);
    	return;
    }
    int main()
    {
    	int t = 0;
    	cin >> t;
    	while(t--)
    	{
    		cin >> n;
    		for(int i = 0;i < n;i ++)
    		{
    			scanf("%d",&arr[i]);
    		}
    		work();
    	}
    	return 0;
    }
    
    

    C

    排列组合 隔板法 尝试让0的分布尽可能均匀而不是只考虑1

    #include <iostream>
    #include <algorithm>
    #include <string>
    #include <vector>
    
    using namespace std;
    typedef long long ll;
    ll n , m;
    void work()
    {
    	ll ans = (n + 1) * n / 2,cnt = (n - m)/(m + 1);
    	ans -= cnt * (cnt+1)/2*(m+1-(n-m)%(m+1)) + (cnt+1)*(cnt+2)/2*((n-m)%(m+1));
    	cout << ans << endl;
    }
    int main()
    {
    	int t;
    	cin >> t;
    	while(t--)
    	{
    		scanf("%lld %lld",&n,&m);
    		work();
    	}
    	return 0;
    }
    
  • 相关阅读:
    kotlin中值范围
    kotlin中集合
    kotlin数据解构
    Java 8 Lambda 表达式
    kotlin 之内联函数
    kotlin之函数的范围和泛型函数
    kotlin函数的参数和返回值
    kotlin 之单表达式函数
    kotlin使用中辍标记法调用函数
    kotlin之函数的基本用法
  • 原文地址:https://www.cnblogs.com/wlw-x/p/12310979.html
Copyright © 2020-2023  润新知