Problem Statement | ||||||||||||||
You are given a square board of size NxN. Each 1x1 cell will be colored either black or white. A rectangle on the board is called good if it contains only white cells. A good rectangle is called perfect if it doesn't lie completely within any other good rectangle. Here's how the board will be colored. You are given ints M, X0, Y0, A, B, C and D. Generate lists X and Y, each of length M, using the following recursive definitions: X[0] = X0 MOD N X[i] = (X[i-1]*A+B) MOD N Y[0] = Y0 MOD N Y[i] = (Y[i-1]*C+D) MOD N The board is initially entirely white. Then, for each i, the cell in column X[i] of row Y[i] is colored black. Return the number of perfect rectangles on the board. | ||||||||||||||
Definition | ||||||||||||||
| ||||||||||||||
Notes | ||||||||||||||
- | The same cell can be painted black multiple times. | |||||||||||||
Constraints | ||||||||||||||
- | N will be between 1 and 2,000, inclusive. | |||||||||||||
- | M will be between 1 and 4,000,000, inclusive. | |||||||||||||
- | X0,Y0,A,B,C,D will each be between 0 and 2,000, inclusive. | |||||||||||||
Examples | ||||||||||||||
0) | ||||||||||||||
| ||||||||||||||
1) | ||||||||||||||
| ||||||||||||||
2) | ||||||||||||||
| ||||||||||||||
3) | ||||||||||||||
|