Recurrent sequences


Plus
Pin


Problem description Progress
ID 38131. Permutation
Темы: Recurrent sequences   

Besi has N (3≤N≤40) favorite points on a 2D lattice, no three of which are collinear. For each 1≤i≤N, the i-th point is given by two integer coordinates xi and yi (0≤xi,y< sub>i≤104).
Besi draws some lines between the points like this:

It selects some permutation p1,p2,…,pN from N points
It draws segments between p1 and p2, p2 and p3, p3< /sub> and p1.
Then for each integer i from 4 to N in order, it draws line segments from pi to pj for all j<i so that this line segment does not intersect any of the previously line segments drawn (outside endpoints)
Besi noticed that for each i, she drew exactly three new segments. Calculate the number of permutations Besi could have chosen in step 1 that satisfy this property modulo 109+7.

Input: 
The first line contains N.
Each of the following N lines contains two space-separated integers xi and yi.

Output: 
Number of permutations modulo 109+7.
 

Examples
# Input Output Explanation
1 4
0 0
04
1 1
1 2
0 No swapping will work.
2 4
0 0
04
40
1 1
24 All permutations work.
3 5
0 0
04
40
1 1
1 2
96 One of the permutations that satisfies the property - (0,0),(0,4),(4,0),(1,2),(1,1).
For this permutation
  • First, it draws lines between each pair of (0,0),(0,4), and (4,0).
  • It then draws lines from (0.0), (0.4), and (4.0) to (1.2).
  • Finally, it draws lines from (1,2), (4,0), and (0,0) to (1,1).
Pattern:

A permutation does not satisfy a property if its first four points are (0,0)(0,0), (1,1)(1,1), (1,2)(1,2), and  (0,4)(0,4) in some order.

ID 38639. Ball on the stairs
Темы: Dynamic Programming: One Parameter    Recurrent sequences   

At the top of the ladder, which contains N stairs, there is a ball that starts jumping down them to the base. The ball can jump to the next step, to the step after one or after 2. (That is, if the ball lies on the 8th step, then it can move to the 5th, 6th or 7th.) Determine the number of possible " ;routes" ball from the top to the ground.


Input

Enter a single number 0 < N < 31.


Output

Print a single number — number of routes.
 

Examples
# Input Output
1 4 7