luogu#P2804. 神秘数字
神秘数字
Background
In the year XXXX, detective Xiao Ming received a secret message from the organization: there is a mysterious door somewhere in Y City. After arriving at the door, he found a line of text: “This door requires a password to unlock.” Xiao Ming searched around and finally found a note: “Now you are given numbers. Please find how many contiguous numbers among these numbers have an average greater than a given number . Note: this number can be very large, so please output the result modulo . The final result is the password to this door.” Xiao Ming pondered for a long time but still couldn’t find the answer, so he turned to you for help. Please solve this problem for him. Since Xiao Ming is in a hurry, he can wait at most second.
Problem Description
Given numbers, help Xiao Ming count how many contiguous subarrays have an average greater than a given number , and output this count. Note: the number can be very large, so please output the result modulo .
Input Format
Two lines.
The first line contains two numbers and .
The second line contains numbers.
Output Format
One line with a single number, which is the answer modulo .
4 3
1 5 4 2
5
4 4
5 2 7 3
6
Hint
Sample explanation:
- For these numbers, the valid solutions are , for a total of groups.
- For these numbers, the valid solutions are , for a total of groups.
Constraints:
- For of the testdata, .
- For of the testdata, .
- For of the testdata, .
- For of the testdata, , , and each number is a positive integer not greater than .
Translated by ChatGPT 5