竞赛讨论区 > 2020湖南省赛H题跪求解答
头像
fancy。
发布于 2020-12-19 23:33
+ 关注

2020湖南省赛H题跪求解答

写了一天了 真不知道错哪了 救救孩子吧
题目链接 https://ac.nowcoder.com/acm/problem/214399

#include
#include 
#include
using namespace std;
typedef long long ll;
const int mod = 1e9+7;
const int k = 1e9;
ll a,b,x1,x2,y1,y2;
ll ans ;
ll cnt(ll a1,ll sum){
    return sum*a1%mod - sum*(sum-1)/2ll % mod;
}
int n = 10;
int main(){
    while(~scanf("%lld%lld",&a,&b)){
        ans = 0;
        scanf("%lld%lld%lld%lld",&x1,&x2,&y1,&y2);
        ans = (cnt(a,a)*cnt(b,b))%mod;
        ans %= mod;
        ll s = ((x2-x1)*(y2-y1)) % mod;
        ans = (ans+((a*b%mod) * s)%mod)%mod;
//        cout<<ans<<endl;
        if(a <= x1 || b <= y1){
            cout<<ans<<endl;
            continue;
        }
        if(a >= x2 && b >= y2)
            ans = (ans-(cnt(a-x1,x2-x1)*cnt(b-y1,y2-y1)%mod))%mod;
        if(a = y2)
            ans = (ans-(cnt(a-x1,a-x1)*cnt(b-y1,y2-y1)%mod))%mod;
        if(a >= x2 && b < y2)
            ans = (ans-(cnt(a-x1,x2-x1)*cnt(b-y1,b-y1)%mod))%mod;
        if(a < x2 && b < y2)
            ans = (ans-(cnt(a-x1,a-x1)*cnt(b-y1,b-y1)%mod))%mod;
        if(ans < 0) ans += mod;
        cout<<ans<<endl;
    }
    return 0;
}

全部评论

(4) 回帖
加载中...
话题 回帖

等你来战

查看全部

热门推荐