zoukankan      html  css  js  c++  java
  • 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;
    }
    
  • 相关阅读:
    Kafka 生产者 自定义分区策略
    同步互斥
    poj 1562 Oil Deposits(dfs)
    poj 2386 Lake Counting(dfs)
    poj 1915 KnightMoves(bfs)
    poj 1664 放苹果(dfs)
    poj 1543 Perfect Cubes (暴搜)
    poj 1166 The Clocks (暴搜)
    poj 3126 Prime Path(bfs)
    处理机调度
  • 原文地址:https://www.cnblogs.com/wlw-x/p/12310979.html
Copyright © 2011-2022 走看看