1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include <iostream>
#include <cmath>
using namespace std;

int main(){
	int n, k, p;
	cin >> n >> k >> p;
	if(k == 1){
		cout << pow(2, n-1) << "\n"; 
	} else if(pow(2, k-1) >= n){
		cout << "0\n";
	} else if(n <= 12){
		int ans[10][4] = {{4, 2, 0, 0},
						{8, 16, 0, 0},
						{16, 100, 4, 0},
						{32, 616, 72, 0},
						{64, 4024, 952, 0},
						{128, 28512, 11680, 0},
						{256, 219664, 142800, 160},
						{512, 1831712, 1788896, 7680},
						{1024, 16429152, 23252832, 233792},
						{2048, 157552000, 315549312, 5898240}};
		cout << ans[n-3][k-1]%p << "\n";
	}
}