아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Travel in Sugar Country

시간 제한1초메모리 제한256 MB

요약
일직선 위 N개 마을에서 서로 다른 K개를 순서대로 고를 때 이동 거리 합이 M의 배수가 되는 경우의 수를 세는 문제이다.
난이도

보통10점 중 7점

유형
동적 계획법, 조합론, 누적 합, 수학
정답자
아직 제출이 없습니다

문제

There are NN towns numbered 11 through NN. There is a bidirectional road between towns ii and i+1i+1, and its length is D_iD\_i. Thus, for each pairs (aa, bb) (a<ba < b), the distance between towns aa and bb is D(a,b)=D_a+D_a+1+…+D_b−1D(a, b) = D\_a + D\_{a+1} + \ldots + D\_{b-1}.

At each town there is a sugar shop. An ant wants to visit KK distinct shops.

The ant wants to choose a set of KK distinct shops and the order to visit them. For example, if it decides to visit the shops S_1,…,S_KS\_1, \ldots, S\_K in this order, the total distance it travels will be D(S_1,S_2)+D(S_2,S_3)+…+D(S_K−1,S_K)D(S\_1, S\_2) + D(S\_2, S\_3) + \ldots + D(S\_{K-1}, S\_K).

In how many ways the total distance it travels become a multiple of MM? Print the answer modulo 109+710^9+7.

입력

NN MM KK 
D_1D\_1 
D_2D\_2 
⋮\vdots 
D_N−1D\_{N-1}

출력

Print the answer modulo 109+710^9+7.

제한

  •  2≤N≤1002 \leq N \leq 100 
  •  1≤M≤301 \leq M \leq 30 
  •  2≤K≤10,K≤N2 \leq K \leq 10, K \leq N 
  •  1≤D_i≤M1 \leq D\_i \leq M 
  • All values in the input are integers.

힌트

In Sample 1, there are six ways: 1→3→21 \rightarrow 3 \rightarrow 2, 2→3→12 \rightarrow 3 \rightarrow 1, 2→1→42 \rightarrow 1 \rightarrow 4, 4→1→24 \rightarrow 1 \rightarrow 2, 2→3→42 \rightarrow 3 \rightarrow 4, and 4→3→24 \rightarrow 3 \rightarrow 2.

예제2

  1. 예제 1

    입력
    4 4 3
    2
    1
    3
    
    예상 출력
    6
    
  2. 예제 2

    입력
    15 5 10
    5
    5
    5
    5
    5
    5
    5
    5
    5
    5
    5
    5
    5
    5
    
    예상 출력
    897286330