AtCoder Beginner Contest 065
C
Reconciled?
AtCoder
⌀ 684
原题
← BD →
翻译中…

Problem Statement

翻译中…

Snuke has $N$ dogs and $M$ monkeys. He wants them to line up in a row.

翻译中…

As a Japanese saying goes, these dogs and monkeys are on bad terms. ("ken'en no naka", literally "the relationship of dogs and monkeys", means a relationship of mutual hatred.) Snuke is trying to reconsile them, by arranging the animals so that there are neither two adjacent dogs nor two adjacent monkeys.

翻译中…

How many such arrangements there are? Find the count modulo $10^9+7$ (since animals cannot understand numbers larger than that). Here, dogs and monkeys are both distinguishable. Also, two arrangements that result from reversing each other are distinguished.

翻译中…

Constraints

翻译中…
  • $1 ≤ N,M ≤ 10^5$
翻译中…

Input

翻译中…

Input is given from Standard Input in the following format:

翻译中…

N M

翻译中…

Output

翻译中…

Print the number of possible arrangements, modulo $10^9+7$.

翻译中…

样例

Input #1
2 2
Output #1
8
We will denote the dogs by `A` and `B`, and the monkeys by `C` and `D`. There are eight possible arrangements: `ACBD`, `ADBC`, `BCAD`, `BDAC`, `CADB`, `CBDA`, `DACB` and `DBCA`.
Input #2
3 2
Output #2
12
Input #3
1 8
Output #3
0
Input #4
100000 100000
Output #4
530123477
题目信息
题号
arc076_a
时间限制
2 s
内存限制
256 MB

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