zoukankan      html  css  js  c++  java
  • HDU

    //水题
    #include <iostream>
    #include <algorithm>
    using namespace std;
    const int maxn = 105;
    int a[7], b[7];
    int store[maxn];
    
    void showa()
    {
    	for (int i = 0; i < 7; i++) cout << a[i] << " ";
    	cout << endl;
    }
    
    void showb()
    {
    	for (int i = 0; i < 7; i++) cout << b[i] << " ";
    	cout << endl;
    }
    
    bool check()
    {
    	for (int i = 0; i < 7; i++)
    	if (b[i] < 0) return false;
    	return true;
    }
    bool GetBFromA()
    {
    	b[6] = a[6];
    	for (int i = 3; i < 6; i++)
    	b[i] = a[i] - a[6];
    	
    	b[0] = a[0] - b[3] - b[5] - b[6];
    	b[1] = a[1] - b[3] - b[4] - b[6];
    	b[2] = a[2] - b[4] - b[5] - b[6];
    	return (check());
    }
    
    int sumb()
    {
    	int sum = 0;
    	for (int i = 0; i < 7; i++) sum += b[i];
    	return sum;
    }
    
    int main()
    {
    	int t, cnt;
    	int N;
    	cin >> t;
    	while (t--)
    	{
    		cnt = 0;
    		cin >> N;
    		for (int i = 0; i < N; i++)
    		{
    			for (int j = 0; j < 7; j++) cin >> a[j];
    		//	showa();
    			GetBFromA();
    		//	showb();
    			if (check())
    			{
    				store[cnt] = sumb(); cnt++;
    		//		cout << "test " << endl;
    			}
    			else
    			continue;	
    		}
    		sort(store, store+cnt);
    		cout << store[--cnt] << endl;
    	}
    	return 0;
    }

  • 相关阅读:
    php责任链模式
    php工厂模式
    php观察者模式
    php单例模式
    php的抽象类
    Mysqli的常用函数
    PDO的基本操作
    算法--各种算法
    file_get_post实现post请求
    redis的5种数据结构的使用场景介绍
  • 原文地址:https://www.cnblogs.com/mofushaohua/p/7789536.html
Copyright © 2011-2022 走看看