ZOJ Problem Set - 3706

简介:

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <set>
#include <iostream>
#include <algorithm>
using namespace std;


set<int> ST;


int find(int a, int b, int c)
{
    ST.clear();

    ST.insert(0);

    ST.insert(a);
    ST.insert(b);
    ST.insert(c);


    ST.insert(a+b);
    ST.insert(a+c);
    ST.insert(b+c);

    ST.insert(abs(a-b));
    ST.insert(abs(b-c));
    ST.insert(abs(a-c));

    ST.insert(abs(a+b-c));
    ST.insert(abs(a+c-b));
    ST.insert(abs(b+c-a));


    ST.insert(a+b+c);

    return ST.size() - 1;
}


int main(void)
{
    int T;
    scanf("%d", &T);

    while(T--)
    {
        int x, y;
        scanf("%d%d", &x, &y);

        int max = -1;

        for(int i = 1; i <= (x/2); ++i)
        {
            int t = find(i, x-i, y);
            if(t > max) max = t;
        }

        for(int i = 1; i <= (y/2); ++i)
        {
            int t = find(x, i, y-i);
            if(t > max) max = t;
        }
        printf("%d\n", max);
    }
}

相关文章
ZOJ - Problem Set - 3960 What Kind of Friends Are You?
ZOJ - Problem Set - 3960 What Kind of Friends Are You?
86 0
ZOJ - Problem Set - 3960 What Kind of Friends Are You?
ZOJ - Problem Set - 3985 String of CCPC
ZOJ - Problem Set - 3985 String of CCPC
99 0
ZOJ Problem Set - 3758 素数
ZOJ Problem Set - 3758 素数
100 0
|
机器学习/深度学习 人工智能 BI
ZOJ Problem Set - 3758 素数
Singles’ Day Time Limit: 2 Seconds Memory Limit: 65536 KB Singles’ Day(or One’s Day), an unofficial holiday in China, is a pop cu...
925 0
|
存储 算法 索引
ZOJ 3505. Yet Another Set of Numbers 解题报告
    ZOJ 3505:Yet Another Set of Numbers     地址:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3505       题意:有一个数字集合,集合中的数遵循以下规则:       ( 1 ).
924 0