#include<bits/stdc++.h> using namespace std; typedef long long LLG; int32_t main(){ ios::sync_with_stdio(false); vector<vector<LLG> > tab = { {0}, {0,1}, {0,2,0}, {0,4,2,0}, {0,8,16,0,0}, {0,16,100,4,0,0}, {0,32,616,72,0,0,0}, {0,64,4024,952,0,0,0,0}, {0,128,28512,11680,0,0,0,0,0}, {0,256,219664LL,142800LL,160,0,0,0,0,0}, {0,512,1831712LL,1788896LL,7680,0,0,0,0,0,0}, {0,1024,16429152LL,23252832LL,233792LL,0,0,0,0,0,0,0}, {0,2048,157552000LL,315549312LL,5898240LL,0,0,0,0,0,0,0,0} }; long long n,k,p; cin >> n >> k >> p; if(n >= tab.size() || k >= tab[n].size()) cout<<0<<endl; else cout<<tab[n][k] % p <<endl; }
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 | #include<bits/stdc++.h> using namespace std; typedef long long LLG; int32_t main(){ ios::sync_with_stdio(false); vector<vector<LLG> > tab = { {0}, {0,1}, {0,2,0}, {0,4,2,0}, {0,8,16,0,0}, {0,16,100,4,0,0}, {0,32,616,72,0,0,0}, {0,64,4024,952,0,0,0,0}, {0,128,28512,11680,0,0,0,0,0}, {0,256,219664LL,142800LL,160,0,0,0,0,0}, {0,512,1831712LL,1788896LL,7680,0,0,0,0,0,0}, {0,1024,16429152LL,23252832LL,233792LL,0,0,0,0,0,0,0}, {0,2048,157552000LL,315549312LL,5898240LL,0,0,0,0,0,0,0,0} }; long long n,k,p; cin >> n >> k >> p; if(n >= tab.size() || k >= tab[n].size()) cout<<0<<endl; else cout<<tab[n][k] % p <<endl; } |