Dogs and monkeys
Very easy
Execution time limit is 1 second
Runtime memory usage limit is 128 megabytes
Barish has dogs and monkeys. He wants to line them up. But he doesn't want to put two dogs or two monkeys together, because in this case they start to fight. How many different arrangements exists, such that neither the monkeys nor the dogs fight. Print the answer modulo . Keep in mind that dogs and monkeys are different.
Input
Two integers and .
Output
Print the number of different ways to arrange monkeys and dogs modulo .
Examples
Input #1
Answer #1
Input #2
Answer #2
Input #3
Answer #3
Submissions 1K
Acceptance rate 34%