luogu#P2804. 神秘数字

    ID: 1870 远端评测题 1000ms 125MiB 尝试: 0 已通过: 0 难度: 6 上传者: 标签>搜索数学线性数据结构二分递归

神秘数字

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 nn numbers. Please find how many contiguous numbers among these nn numbers have an average greater than a given number MM. Note: this number can be very large, so please output the result modulo 9208493192084931. 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 11 second.

Problem Description

Given nn numbers, help Xiao Ming count how many contiguous subarrays have an average greater than a given number MM, and output this count. Note: the number can be very large, so please output the result modulo 9208493192084931.

Input Format

Two lines.
The first line contains two numbers nn and MM.
The second line contains nn numbers.

Output Format

One line with a single number, which is the answer modulo 9208493192084931.

4 3
1 5 4 2
5
4 4
5 2 7 3
6

Hint

Sample explanation:

  1. For these 44 numbers, the valid solutions are {5},{4},{5,4},{1,5,4},{5,4,2}\{5\},\{4\},\{5,4\},\{1,5,4\},\{5,4,2\}, for a total of 55 groups.
  2. For these 44 numbers, the valid solutions are {5},{7},{2,7},{7,3},{5,2,7},{5,2,7,3}\{5\},\{7\},\{2,7\},\{7,3\},\{5,2,7\},\{5,2,7,3\}, for a total of 66 groups.

Constraints:

  • For 10%10\% of the testdata, 1<n101 < n \le 10.
  • For 30%30\% of the testdata, 1<n10001 < n \le 1000.
  • For 50%50\% of the testdata, 1<n300001 < n \le 30000.
  • For 100%100\% of the testdata, 1<n2000001 < n \le 200000, 1<M30001 < M \le 3000, and each number is a positive integer not greater than 50005000.

Translated by ChatGPT 5