This problem is primary Mathematical Olympiad ah.
Meaning of the questions: seeking \ (m \) different items pairwise adjacent program number.
Direct permutations.
We can lose them requires a minimum number of bits between vacated - \ (m-1 \) vacancies
Thus, we only use left \ (m-1 \) vacancies on each of the two intermediate articles so that they can be pairwise adjacent.
So the rest Location \ (n-m + 1 \ ) vacancies.
The problem is transformed into this question:
Given \ (n-m + 1 \ ) seats, into m number of different items of the program.
Direct arrangement just fine.
\ (years \) = \ (A_ {n-m + 1} ^ {m} \)
#include<bits/stdc++.h>
using namespace std;
int type,n,m,mod,cnt;
long long ans=1;
int main()
{
scanf("%d%d%d%d",&type,&n,&m,&mod);
for(int i=n-m+1;i>=n-2*m+2;i--)
{
ans=(ans*i)%mod;
}
printf("%lld\n",ans);
return 0;
}