#abc207e. E - Mod i

E - Mod i

Score : 500500 points

问题描述

已知一个包含 NN 个数的序列 AA。找出将 AA 分割成若干个非空连续子序列 B1,B2,,BkB_1, B_2, \ldots, B_k 的方法数量,使得满足以下条件:

  • 对于每个 i (1ik)i\ (1 \leq i \leq k),子序列 BiB_i 中元素的和能够被 ii 整除。

由于计数结果可能会非常大,请以 (109+7)(10^9+7) 为模,输出最终答案。

以上为通义千问 qwen-max 翻译,仅供参考。

Problem Statement

Given is a sequence AA of NN numbers. Find the number of ways to separate AA into some number of non-empty contiguous subsequence B1,B2,,BkB_1, B_2, \ldots, B_k so that the following condition is satisfied:

  • For every i (1ik)i\ (1 \leq i \leq k), the sum of elements in BiB_i is divisible by ii.

Since the count can be enormous, print it modulo (109+7)(10^9+7).

Constraints

  • 1N30001 \leq N \leq 3000
  • 1Ai10151 \leq A_i \leq 10^{15}
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

NN

A1A_1 A2A_2 \ldots ANA_N

Output

Print the number of ways to separate the sequence so that the condition in the Problem Statement is satisfied, modulo (109+7)(10^9+7).

Sample Input 1

4
1 2 3 4

Sample Output 1

3

We have three ways to separate the sequence, as follows:

  • (1),(2),(3),(4)(1),(2),(3),(4)
  • (1,2,3),(4)(1,2,3),(4)
  • (1,2,3,4)(1,2,3,4)

Sample Input 2

5
8 6 3 3 3

Sample Output 2

5

Sample Input 3

10
791754273866483 706434917156797 714489398264550 918142301070506 559125109706263 694445720452148 648739025948445 869006293795825 718343486637033 934236559762733

Sample Output 3

15

The values in input may not fit into a 3232-bit integer type.

update @ 2024/3/10 09:21:03