Under construction

Still being built. Things may change

Quadratic Function

Time limit2sMemory limit1024 MB

Summary
Given f(x)=(x-a)(x-b), pick n-1 interior points with increasing x between a and b to maximize the area of their convex polygon, printed modulo 1000000007.
Level

Medium7 of 10

Topics
Dynamic programming, Geometry, Math
Solved
No attempts yet

Problem

A quadratic function f(x)=(x−a)(x−b)f(x) = (x-a)(x-b) is given.

Place n+1n+1 points on the graph y=f(x)y = f(x), namely (x0,f(x0)),(x1,f(x1)),⋯ ,(xn,f(xn))(x_0, f(x_0)), (x_1, f(x_1)), \cdots, (x_n, f(x_n)), where a=x0<x1<x2<⋯<xn=ba = x_0 < x_1 < x_2 < \cdots < x_n = b. Find the maximum area of the convex polygon formed by these n+1n+1 points.

For every input, the answer is always a rational number.

Input

The first line contains an integer nn. (2≤n≤1 0002 \leq n \leq 1\,000)

The second line contains two integers aa and bb. (0≤a<b≤1 0000 \leq a < b \leq 1\,000)

Output

Let the maximum area be pq\frac{p}{q}, where pp and qq are coprime positive integers. Print the integer vv with 0≤v≤1 000 000 0060 \leq v \leq 1\,000\,000\,006 such that q⋅v≡p(mod1 000 000 007)q \cdot v \equiv p \pmod{1\,000\,000\,007}.

Such vv always exists for every input.

Examples3

  1. Example 1

    Input
    3
    0 3
    
    Expected output
    4
    
  2. Example 2

    Input
    2
    0 1
    
    Expected output
    125000001
    
  3. Example 3

    Input
    13
    17 99
    
    Expected output
    361038099