题目链接:ZOJ 3706 Break Standard Weight
这次的浙江省赛是暴力专场吧==。
把所有情况列都出来,用map去重,找最大值。
#include <iostream>
#include <cstring>
#include <cstdio>
#include <map>
using namespace std;
int a, b, _max;
map <int, int> _count;
int getSum(int x, int y, int z)
{
if(!_count.count(x))
_count[x] = 1;
if(!_count.count(y))
_count[y] = 1;
if(!_count.count(z))
_count[z] = 1;
if(!_count.count(x + y))
_count[x + y] = 1;
if(!_count.count(x + z))
_count[x + z] = 1;
if(!_count.count(y + z))
_count[y + z] = 1;
if(x - y > 0 && !_count.count(x - y))
_count[x - y] = 1;
if(x - z > 0 && !_count.count(x - z))
_count[x - z] = 1;
if(y - z > 0 && !_count.count(y - z))
_count[y - z] = 1;
if(y - x > 0 && !_count.count(y - x))
_count[y - x] = 1;
if(z - x > 0 && !_count.count(z - x))
_count[z - x] = 1;
if(z - y > 0 && !_count.count(z - y))
_count[z - y] = 1;
if(!_count.count(x + y + z))
_count[x + y + z] = 1;
if(x + y - z > 0 && !_count.count(x + y - z))
_count[x + y - z] = 1;
if(x + z - y > 0 && !_count.count(x + z - y))
_count[x + z - y] = 1;
if(z + y - x > 0 && !_count.count(z + y - x))
_count[z + y - x] = 1;
if(x - y - z > 0 && !_count.count(x - y - z))
_count[x - y - z] = 1;
if(y - x - z > 0 && !_count.count(y - x - z))
_count[y - x - z] = 1;
if(z - x - y > 0 && !_count.count(z - x - y))
_count[z - x - y] = 1;
_max = max(_max, (int)_count.size());
_count.clear();
}
void resolve()
{
int l = 1, r = a - 1, t = 0;
while(l <= r)
{
getSum(l, r, b);
l++, r--;
}
l = 1, r = b - 1;
while(l <= r)
{
getSum(l, r, a);
l++, r--;
}
}
int main()
{
int T;
scanf("%d", &T);
while(T--)
{
scanf("%d%d", &a, &b);
_max = 1;
resolve();
printf("%d\n", _max);
}
return 0;
}