ZOJ Problem Set - 3706

时间:2023-03-09 18:12:50
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(); 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() - ;
} int main(void)
{
int T;
scanf("%d", &T); while(T--)
{
int x, y;
scanf("%d%d", &x, &y); int max = -; for(int i = ; i <= (x/2); ++i)
{
int t = find(i, x-i, y);
if(t > max) max = t;
} for(int i = ; i <= (y/2); ++i)
{
int t = find(x, i, y-i);
if(t > max) max = t;
}
printf("%d\n", max);
}
}