시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
1 초 | 512 MB | 1 | 0 | 0 | 0.000% |
A pretty table is a grid with N rows and N columns containing integers from 1 to N2. The numbers are written on the grid following these rules:
For example, if N = 5, the table will look like this:
Given N, R1, R2, C1, and C2, calculates the sum of the integers contained within the sub-grid having (R1, C1) and (R2, C2) as the top-left-most cell and the bottom-right-most cell. Note that the table index starts from 1 to N on both row and column.
The input contains five integers in a line: N R1 R2 C1 C2 (1 ≤ N ≤ 1,000,000,000; 1 ≤ R1 ≤ R2 ≤ N; 1 ≤ C1 ≤ C2 ≤ N) as stated in the problem description.
The output contains the remainder of the answer when divided by 1,000,000,007, in a line.
5 3 3 3 3
1
5 1 5 1 5
325
5 4 5 4 5
70
1 1 1 1 1
1
ICPC > Regionals > Asia Pacific > Indonesia > Indonesia National Contest > INC 2017 L번