#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int mxn=1e9+5,M=1e9+7;
int n,q;
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin>>n>>q;
while(q--){
int x,y,xx,yy;
cin>>y>>x>>yy>>xx;
ll w=max(abs(x),abs(y));
ll z=(w*2+1)%M,zz=(z*z)%M;
if(-w==x){
assert((zz-(w-y)+M*2)%M >=0);
cout<<(zz-(w-y)+M*2)%M<<'\n';
continue;
}
zz-=z-1;
zz+=M;
zz%=M;
if(-w==y){
assert((zz-(x+w-1)+M*2)%M >=0);
cout<<(zz-(x+w-1)+M*2)%M<<'\n';
continue;
}
zz-=z-1;
zz+=M;
zz%=M;
if(x==w){
assert((zz-(x+w-1)+M*2)%M >=0);
cout<<(zz-(x+w-1)+M*2)%M<<'\n';
continue;
}
zz-=z-1;
zz+=M;
zz%=M;
assert((zz-(w-1-x)+M*2)%M >=0);
cout<<(zz-(w-1-x)+M*2)%M<<'\n';
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |