TopCoder

Caido
Waimai

User's AC Ratio

85.7% (6/7)

Submission's AC Ratio

68.8% (11/16)

Tags

Description

現在你有四個整數 n,X,Y,Z,你想要從 10n 個長度為 n,每個數字 ai110 的序列中 (即序列為a1,...,an,1ai10),找出滿足以下條件的序列數量 (mod 109+7):
你能找到四個數字 1x<y<z<wn+1,使得
ax+...+ay1=X
ay+...+az1=Y
az+...+aw1=Z

Input Format

輸入只有一行四個整數,分別代表題目中的 n,X,Y,Z
對於所有測資,
3n40
1X5
1Y7
1Z5

Output Format

輸出一個整數,代表你認為的答案。

Sample Input 1

3 5 7 5

Sample Output 1

1

Sample Input 2

37 4 2 3

Sample Output 2

863912418

Sample Input 3

4 5 7 5

Sample Output 3

34

Sample Input 4

40 5 7 5

Sample Output 4

562805100

Hints

第一筆範測中,在103種序列中,只有(5,7,5)符合條件,因此答案為1

Problem Source

Subtasks

No. Testdata Range Constraints Score
1 0~3 範例測資 0
2 0~34 無額外限制 100

Testdata and Limits

No. Time Limit (ms) Memory Limit (VSS, KiB) Output Limit (KiB) Subtasks
0 1000 65536 65536 1 2
1 1000 65536 65536 1 2
2 1000 65536 65536 1 2
3 1000 65536 65536 1 2
4 1000 65536 65536 2
5 1000 65536 65536 2
6 1000 65536 65536 2
7 1000 65536 65536 2
8 1000 65536 65536 2
9 1000 65536 65536 2
10 1000 65536 65536 2
11 1000 65536 65536 2
12 1000 65536 65536 2
13 1000 65536 65536 2
14 1000 65536 65536 2
15 1000 65536 65536 2
16 1000 65536 65536 2
17 1000 65536 65536 2
18 1000 65536 65536 2
19 1000 65536 65536 2
20 1000 65536 65536 2
21 1000 65536 65536 2
22 1000 65536 65536 2
23 1000 65536 65536 2
24 1000 65536 65536 2
25 1000 65536 65536 2
26 1000 65536 65536 2
27 1000 65536 65536 2
28 1000 65536 65536 2
29 1000 65536 65536 2
30 1000 65536 65536 2
31 1000 65536 65536 2
32 1000 65536 65536 2
33 1000 65536 65536 2
34 1000 65536 65536 2