F - Faraway HDU - 6639(思维+枚举)

问题虫洞:Faraway

 

黑洞内窥:

给出n个形如 (|xi−xe|+|yi−ye|) % ki=ti.

以及xi,xe, yi, ye 的最大范围m

( 1<= ki <=5, 0<= ti <=4)

求有多少对(xe, ye)符合这n个式子

 

思维光年:

我的思路: 枚举m,以60为单位,but,,这只是一个x,,,你还要枚举y。。

 

理性的求解:

 

ACcode:

//#include<bits/stdc++.h>
#include  <stdio.h>
#include <iostream>
#include<algorithm>
#include      <map>
#include      <set>
#include   <vector>
#include    <queue>
#include    <stack>
#include <stdlib.h>
#include  <cstring>
#include <string.h>
#include   <string>
#include   <math.h>
#include  <sstream>
using namespace std;
typedef long long int ll;
const ll MAXN = 100005;
#define INF 0x3f3f3f3f//将近ll类型最大数的一半,而且乘2不会爆ll
const ll mod = 2100000007;
const double eps = 0.00000001;
const double pi = acos(-1);

int b[20], c[20], x[20], y[20], xe[20], ye[20];
int t, n, m;
int is(int x, int y)
{
    for(int i=1; i<=n; ++i)
    {
        if((abs(x-xe[i]) + abs(y-ye[i]))%b[i] != c[i])
            return 0;
    }
    return 1;
}

ll qv(int l, int r)
{
    r-=l;
    if(r < 0) return 0;
    else return r/60+1;
}

int main()
{
    cin >> t;
    while(t--)
    {
        scanf("%d %d", &n, &m);
        ll ans = 0;
        for(int i=1; i<=n; ++i)
            scanf("%d %d %d %d", &xe[i], &ye[i], &b[i], &c[i]);
        x[0] = 0, y[0] = 0;     //一个正方形边界
        x[n+1] = m+1, y[n+1] = m+1;
        
        for(int i=1; i<=n; ++i)
            x[i] = xe[i], y[i] = ye[i];
        sort(x, x+n+2);
        sort(y, y+n+2);
        for(int i=0; i<=n; ++i)//枚举(n+1)^2个区域
            for(int j=0; j<=n; ++j)
                for(int k=0; k<60; ++k)//枚举xe和ye
                    for(int h=0; h<60; ++h)
                    {
                        int xx = x[i]+k, yy = y[j]+h;
                        if(is(xx, yy))//计算区域的点
                            ans+=qv(xx, x[i+1]-1)*qv(yy, y[j+1]-1);
                    }
        cout << ans << '\n';
    }
    return 0;
}

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值