← All problemsSign in

Suffix Palindromes

Consider an alphabet with $S$ characters. Find the number of strings with length $N$ containing only characters from this alphabet which do not have any palindromic suffix with length greater than $1$. Since this number may be very large, compute it modulo $M$. ### Input The first and only line of the input contains three space-separated integers $N$, $S$ and $M$. ### Output Print a single line

HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17

CodeSearch Tutor

Hints, not spoilers — it won’t hand over the full solution unless you insist.

voice by Sarvam AI

Sign in to chat with the tutor and save your progress.

Sign in to start