#include #include #include #include #include #include using namespace std; int H,W,n,m; int x[555555],y[555555],cnt1[3533][3533],cnt2[3533][3533]; const int shift=1100; int calc_rec2(int x1,int y1,int x2,int y2){ if (x1>x2) swap(x1,x2); if (y1>y2) swap(y1,y2); return cnt2[x2][y2]-cnt2[x1-1][y2]-cnt2[x2][y1-1]+cnt2[x1-1][y1-1]; } int calc_rec1(int x1,int y1,int x2,int y2){ if (x1>x2) swap(x1,x2); if (y1>y2) swap(y1,y2); if (x1<1) x1=1; if (y1<1) y1=1; if (x2>3500) x2=3500; if (y2>3500) y2=3500; return cnt1[x2][y2]-cnt1[x1-1][y2]-cnt1[x2][y1-1]+cnt1[x1-1][y1-1]; } int calc(int x,int y,int len){ int tx=x+y+shift,ty=x-y+shift; int ret=0; if ((x+y)%2==0){// confirm cnt1 ret+=calc_rec1(tx-len,ty-len,tx+len,ty+len); //ret+=calc_rec2(tx-len,ty-len,tx+len,ty+len); }else { ret+=calc_rec1(tx-len,ty-len,tx+len,ty+len); //ret+=calc_rec2(tx-len,ty-len,tx+len,ty+len); } return ret; } int main(){ int num=0; while(cin >> H >> W >> n >> m){ if (!H&&!W&&!n&&!m) break; for (int i=0;ians){ ans=tmp; posx=i; posy=j; } } cout << ans <<" (" << posx <<","<< posy <<")" << endl; } } } /* 4 4 5 3 1 1 1 2 3 3 4 4 2 4 1 2 400000 4 4 5 3 1 1 1 2 3 3 4 4 2 4 1 2 4 4 4 5 3 1 1 1 2 3 3 4 4 2 4 1 2 4 0 0 0 0 */