Problem description in Excel:
Today, Chen zeyu found three more sisters who had a favorite hobby. He wanted to find three places to hide the sisters and abstract a blank space into a table in Column C of row R, select three cells for czy. However, the following two conditions must be met:
(1) Any two cells are not in the same row.
(2) Any two cells are not in the same column.
There is a cost for selecting a grid, and the cost is the sum (for example, X1, Y1) and (x, Y2) of the Manhattan distance between the three grids) the Manhattan distance is | x1-x2 | + | y1-y2 | ). What the dog wants to know is how many solutions are spent between mint and maxt.
The answer model is 1000000007. The two different schemes refer to different schemes as long as the selected cells have different ones.
Input Format:
A row with four integers: R, C, mint, and maxt. 3 ≤ r, c ≤ 4000, 1 ≤ mint ≤ maxt ≤ 20000.
For 30% of data, 3 ≤ r, c ≤ 70.
Output Format:
An integer that represents the result after the number of different options is 1000000007.
Input and Output example:
Input example |
3 3 1 20000 |
3 3 4 7 |
4 6 9 12 |
7 5 13 18 |
4000 4000 4000 14000 |
Output example |
6 |
0 |
264 |
1212 |
859690013 |
Ideas:
I will say that I have no idea... It basically carries the huge hzwer yellow code...
Let's go in tomorrow and try again later.
Code:
#include<iostream>#include<cstdlib>#include<cstdio>#define mod 1000000007using namespace std;long long ans=0;int t1[10001];int t2[10001];int R,C,minT,maxT; int main(){ freopen("excel.in","r",stdin); freopen("excel.out","w",stdout); cin>>R>>C>>minT>>maxT; for (int i=1;i<=R;i++) t1[i]=(R-i)*(i-1); for (int j=1;j<=C;j++) t2[j]=(C-j)*(j-1); for (int i=1;i<=R;i++) for (int j=1;j<=C;j++) { if ( ( (2*(i+j))>=minT ) && ( (2*(i+j))<=maxT ) ) { ans=(ans+ ((long long)t1[i]*t2[j]*6)%mod )%mod; } } cout<<ans; return 0;}
Result:
It took me so long... Why is there more than two seconds for the same code to be handed over, and more than four seconds for the same code? It must be that the huge yellow RP is higher than me... (/Inferiority)
[Messing around] [medium difficulty] noip simulation contest Tibetan girl