Concatenation of two palindromes
Very easy
Execution time limit is 2 seconds
Runtime memory usage limit is 128 megabytes
Find the number of ways to construct a string of length using Latin letters (the size of the alphabet is ) as the concatenation of two nonempty palindromes.
Input
Two positive integers and .
Output
Print the number of ways to construct the given string. Print the answer modulo .
Examples
In the first test case the string of length using one letter ( for example) can be constructed in three ways: .
Input #1
Answer #1
Input #2
Answer #2
Submissions 1K
Acceptance rate 37%