//Krzysztof Boryczka #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef pair<int, int> ii; typedef vector<int> vi; typedef vector<ii> vii; const int inf=0x3f3f3f3f; const ll INF=0x3f3f3f3f3f3f3f3f; #define FOR(i, b, e) for(int i=b; i<=e; i++) #define FORD(i, b, e) for(int i=b; i>=e; i--) #define SIZE(x) ((int)(x).size()) #define pb push_back #define st first #define nd second #define sp ' ' #define ent '\n' #define WATCH(x) cout<<(#x)<<" is "<<(x)<<ent //END OF TEMPLATE int t[100][100]; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); int n, k, p; FOR(i, 2, 20){ t[i][1]=pow(2, i-1); } t[3][2]=2; t[4][2]=16; t[5][2]=100; t[5][3]=4; t[6][2]=616; t[6][3]=72; t[7][2]=4024; t[7][3]=952; t[8][2]=28512; t[8][3]=11680; t[9][2]=219664; t[9][3]=142800; t[9][4]=160; t[10][2]=1831712; t[10][3]=1788896; t[10][4]=7680; t[11][2]=16429152; t[11][3]=23252832; t[11][4]=233792; t[12][2]=157552000; t[12][3]=315549312; t[12][4]=5898240; cin>>n>>k>>p; cout<<t[n][k]%p<<ent; return 0; }
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 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | //Krzysztof Boryczka #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef pair<int, int> ii; typedef vector<int> vi; typedef vector<ii> vii; const int inf=0x3f3f3f3f; const ll INF=0x3f3f3f3f3f3f3f3f; #define FOR(i, b, e) for(int i=b; i<=e; i++) #define FORD(i, b, e) for(int i=b; i>=e; i--) #define SIZE(x) ((int)(x).size()) #define pb push_back #define st first #define nd second #define sp ' ' #define ent '\n' #define WATCH(x) cout<<(#x)<<" is "<<(x)<<ent //END OF TEMPLATE int t[100][100]; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); int n, k, p; FOR(i, 2, 20){ t[i][1]=pow(2, i-1); } t[3][2]=2; t[4][2]=16; t[5][2]=100; t[5][3]=4; t[6][2]=616; t[6][3]=72; t[7][2]=4024; t[7][3]=952; t[8][2]=28512; t[8][3]=11680; t[9][2]=219664; t[9][3]=142800; t[9][4]=160; t[10][2]=1831712; t[10][3]=1788896; t[10][4]=7680; t[11][2]=16429152; t[11][3]=23252832; t[11][4]=233792; t[12][2]=157552000; t[12][3]=315549312; t[12][4]=5898240; cin>>n>>k>>p; cout<<t[n][k]%p<<ent; return 0; } |