• 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;
    }
    
  • 相关阅读:
    busybox 注意事项
    Implicit vs Explicit Sharing
    Font Creator Program 字库修改合并软件
    Iperf 源代码分析(四)
    QML 中文支持
    file operation
    MFC异常 与C++标准异常
    统一建模语言(UML) 版本 2.0
    MultiByteToWideChar和WideCharToMultiByte用法详解
    UML 基础: 类图
  • 原文地址:https://www.cnblogs.com/wlw-x/p/12310979.html
Copyright © 2020-2023  润新知