真的不知道错哪里了 求解答
题目链接:https://ac.nowcoder.com/acm/contest/9699/H
#include<iostream> #include<cstdio> #include<cstdlib> 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 < x2 && b >= 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; }
写了一天了 聚聚们救救孩子吧
全部评论
(0) 回帖