#P6475. [NOI Online #2 入门组] 建设城市
[NOI Online #2 入门组] 建设城市
Problem Description
Qiuqiu is an architect. One day, he received a task from the mayor: build a city. Qiuqiu plans to build skyscrapers. To make the city look nice, Qiuqiu makes the following plan:
-
Qiuqiu likes neat things. He wants the skyscrapers to be arranged in a line from left to right, numbered .
-
Qiuqiu likes integers. He requires the height of each skyscraper to be a positive integer.
-
Due to material limits, the height of any skyscraper cannot exceed .
-
Qiuqiu likes a shape that is high in the middle and low on both sides. He requires that the heights of the first skyscrapers do not decrease, and the heights of the last skyscrapers do not increase.
-
Qiuqiu plans to choose two skyscrapers with indices as the landmarks of the city. He believes the city looks nice only when these two skyscrapers have the same height.
Qiuqiu told the mayor his idea. The mayor wants to know the total number of possible building plans. Two plans are different if and only if there exists a skyscraper whose height is different in the two plans. This problem stumped Qiuqiu, so he came to you for help. Since the answer may be very large, you only need to output the result modulo .
Input Format
Read data from standard input.
There is only one line with four integers . The meanings of the variables are given in the statement.
Output Format
Write to standard output.
Output one line containing one integer, the answer.
3 2 1 3
10
1000 1000 535 1477
295916566
Hint
For sample , all plans are: $\{1,1,1,1\},\{1,2,1,1\},\{1,3,1,1\},\{2,2,2,1\},\{2,2,2,2\},\\\{2,3,2,1\},\{2,3,2,2\},\{3,3,3,1\},\{3,3,3,2\},\{3,3,3,3\}$.
For of the testdata, .
For of the testdata, .
For of the testdata, .
For of the testdata, , .
Translated by ChatGPT 5