2017年10月07日普及组 单元格
程序:
const
mods:longint=1000000007;
var
r,c,min,max,i:longint;
sum1,sum2:array[0..4001]of int64;
function work(t:longint):int64;
var
i,j:longint;
ans,tmp:int64;
begin
if t<8 then exit(0);
ans:=0;
for i:=2 to r-1 do
begin
j:=(t-2*i) div 2;
if j<2 then break;
if j+1>=c then tmp:=6*(r-i)*(i-1)*sum2[c-2] mod mods else tmp:=6*(r-i)*(i-1)*(sum1[j-1]*(c-j)+sum2[j-2]) mod mods;
ans:=(ans+tmp) mod mods;
end;
exit(ans);
end;
begin
readln(r,c,min,max);
for i:=1 to 4001 do
begin
sum1[i]:=sum1[i-1]+i;
sum2[i]:=sum2[i-1]+sum1[i];
end;
writeln((work(max)+mods-work(min-1)) mod mods);
end.