ZOJ 3706 Break Standard Weight

题目链接: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;
}



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值