Codeforces Round 533 (Div. 2)
C
Ayoub and Lost Array
Codeforces
1500
原题
← BD →
翻译中…

Ayoub had an array $a$ of integers of size $n$ and this array had two interesting properties:

翻译中…
  • All the integers in the array were between $l$ and $r$ (inclusive).
  • The sum of all the elements was divisible by $3$.
翻译中…

Unfortunately, Ayoub has lost his array, but he remembers the size of the array $n$ and the numbers $l$ and $r$, so he asked you to find the number of ways to restore the array.

翻译中…

Since the answer could be very large, print it modulo $10^9 + 7$ (i.e. the remainder when dividing by $10^9 + 7$). In case there are no satisfying arrays (Ayoub has a wrong memory), print $0$.

翻译中…

Input

翻译中…

The first and only line contains three integers $n$, $l$ and $r$ ($1 \le n \le 2 \cdot 10^5 , 1 \le l \le r \le 10^9$) — the size of the lost array and the range of numbers in the array.

翻译中…

Output

翻译中…

Print the remainder when dividing by $10^9 + 7$ the number of ways to restore the array.

翻译中…

Note

翻译中…

In the first example, the possible arrays are : $[1,2], [2,1], [3, 3]$.

翻译中…

In the second example, the only possible array is $[2, 2, 2]$.

翻译中…

样例

Input #1
2 1 3
Output #1
3
InputCopy OutputCopy
Input #2
3 2 2
Output #2
1
InputCopy OutputCopy
Input #3
9 9 99
Output #3
711426616
InputCopy OutputCopy
题目信息
题号
1105C
时间限制
1 s
内存限制
256 MB
标签
组合数学
动态规划
数学

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。